feat: ✨ [first attempt at using MySQLi in the docker dev env]
This commit is contained in:
parent
472ec10496
commit
1862ccbbb6
5 changed files with 21 additions and 2 deletions
|
@ -12,6 +12,7 @@ RUN chmod -R a+r ./vendor
|
|||
|
||||
RUN a2enmod rewrite
|
||||
RUN a2enmod headers
|
||||
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
|
||||
|
||||
COPY . .
|
||||
RUN chmod -R a+r $(ls -I vendor)
|
||||
|
|
4
docker_dev/MysqlDockerfile
Normal file
4
docker_dev/MysqlDockerfile
Normal file
|
@ -0,0 +1,4 @@
|
|||
FROM mysql:8.0-debian
|
||||
|
||||
WORKDIR /docker-entrypoint-initdb.d
|
||||
COPY mysql_schema.sql ./
|
|
@ -11,9 +11,12 @@ services:
|
|||
action: rebuild
|
||||
- path: ../.
|
||||
action: sync
|
||||
target: /usr/local/apache2/htdocs/
|
||||
target: /var/www/html
|
||||
ignore:
|
||||
- ../.git
|
||||
mysql:
|
||||
image: mysql:8.0-debian
|
||||
build:
|
||||
dockerfile: MysqlDockerfile
|
||||
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
|
||||
# (this is just an example, not intended to be a production configuration)
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
|
|
0
docker_dev/mysql_schema.sql
Normal file
0
docker_dev/mysql_schema.sql
Normal file
11
router.php
11
router.php
|
@ -2,6 +2,17 @@
|
|||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
|
||||
$sql = mysqli_connect('mysql', 'root', 'example', 'mysql');
|
||||
|
||||
if (!$sql)
|
||||
{
|
||||
echo 'Connection failed<br>';
|
||||
echo 'Error number: ' . mysqli_connect_errno() . '<br>';
|
||||
echo 'Error message: ' . mysqli_connect_error() . '<br>';
|
||||
die();
|
||||
}
|
||||
|
||||
$loader = new \Twig\Loader\FilesystemLoader(['./templates', './user_content']);
|
||||
|
||||
$twig = new \Twig\Environment($loader,['debug' => true]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue