feat: [first attempt at using MySQLi in the docker dev env]

This commit is contained in:
David Bailey 2023-10-16 16:15:24 +02:00
parent 472ec10496
commit 1862ccbbb6
5 changed files with 21 additions and 2 deletions

View file

@ -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)

View file

@ -0,0 +1,4 @@
FROM mysql:8.0-debian
WORKDIR /docker-entrypoint-initdb.d
COPY mysql_schema.sql ./

View file

@ -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

View file

View file

@ -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]);