Skip to content

Commit ec0a2da

Browse files
committed
feature: updated to Symfony 6.1 and PHP 8.1
1 parent 3d64595 commit ec0a2da

22 files changed

+975
-1147
lines changed

.docker/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
COMPOSE_PROJECT_NAME=symfony_docker
1+
COMPOSE_PROJECT_NAME=symfony_dockerized
22
MYSQL_ROOT_PASSWORD=hello
33
MYSQL_DATABASE=app_db
44
MYSQL_USER=app_user

.docker/docker-compose.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ version: "3"
22

33
services:
44
db:
5-
image: mysql:8.0.20
5+
image: mysql:8.0.23
6+
platform: linux/x86_64
67
command: --default-authentication-plugin=mysql_native_password
78
volumes:
89
- "db_app:/var/lib/mysql"
@@ -21,14 +22,14 @@ services:
2122
args:
2223
TIMEZONE: ${TIMEZONE}
2324
volumes:
24-
- symfony_docker_app_sync:/var/www/symfony/
25+
- symfony_dockerized_app_sync:/var/www/symfony/
2526
networks:
2627
- symfony
2728
nginx:
2829
build:
2930
context: ./nginx
3031
volumes:
31-
- symfony_docker_app_sync:/var/www/symfony/
32+
- symfony_dockerized_app_sync:/var/www/symfony/
3233
ports:
3334
- 80:80
3435
networks:
@@ -37,7 +38,7 @@ services:
3738
- .env.nginx.local
3839

3940
volumes:
40-
symfony_docker_app_sync:
41+
symfony_dockerized_app_sync:
4142
external: true
4243
db_app:
4344

.docker/docker-sync.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ options:
55
verbose: true
66

77
syncs:
8-
symfony_docker_app_sync:
8+
symfony_dockerized_app_sync:
99
src: "../"
1010
sync_userid: "33"
1111
sync_excludes:

.env

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
COMPOSE_PROJECT_NAME=symfony_docker
1+
COMPOSE_PROJECT_NAME=symfony_dockerized
2+
23
# In all environments, the following files are loaded if they exist,
34
# the latter taking precedence over the former:
45
#
@@ -12,19 +13,13 @@ COMPOSE_PROJECT_NAME=symfony_docker
1213
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
1314
#
1415
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15-
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
16-
17-
###> symfony/framework-bundle ###
18-
APP_ENV=dev
19-
APP_SECRET=cb59b41603c2f9ee8360cb364f2dba1a
20-
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
21-
#TRUSTED_HOSTS='^localhost|example\.com$'
22-
###< symfony/framework-bundle ###
16+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
2317

2418
###> doctrine/doctrine-bundle ###
2519
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
26-
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
27-
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
2820
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
29-
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7
21+
#
22+
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
23+
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7&charset=utf8mb4"
24+
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name?serverVersion=8.0.23
3025
###< doctrine/doctrine-bundle ###

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.env.local
44
/.env.local.php
55
/.env.*.local
6+
/config/secrets/prod/prod.decrypt.private.php
67
/public/bundles/
78
/var/
89
/vendor/

Readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# 🐳 Docker + PHP 8.0 + MySQL + Nginx + Symfony 5.3 Boilerplate
1+
# 🐳 Docker + PHP 8.1 + MySQL + Nginx + Symfony 6.1 Boilerplate
22

33
## Description
44

5-
This is a complete stack for running Symfony 5.3 into Docker containers using docker-compose tool with [docker-sync library](https://docker-sync.readthedocs.io/en/latest/).
5+
This is a complete stack for running Symfony 6.1 into Docker containers using docker-compose tool with [docker-sync library](https://docker-sync.readthedocs.io/en/latest/).
66

77
It is composed by 4 containers:
88

@@ -26,13 +26,13 @@ It is composed by 4 containers:
2626
6. Use the following value for the DATABASE_URL environment variable:
2727

2828
```
29-
DATABASE_URL=mysql://app_user:helloworld@db:3306/app_db?serverVersion=5.7
29+
DATABASE_URL=mysql://app_user:helloworld@db:3306/app_db?serverVersion=8.0.23
3030
```
3131

3232
You could change the name, user and password of the database in the `env` file at the root of the project.
3333

3434
## To learn more
3535

36-
I have recorded a Youtube session explaining the different parts of this project. You could see it here:
36+
I have recorded a Youtube session explaining the different parts of this project. You could see it here:
3737

3838
[Boilerplate para Symfony basado en Docker, NGINX y PHP8](https://youtu.be/A82-hry3Zvw)

bin/console

+7-32
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,15 @@
33

44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\ErrorHandler\Debug;
86

9-
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
10-
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
7+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
8+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
119
}
1210

13-
set_time_limit(0);
11+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
1412

15-
require dirname(__DIR__).'/vendor/autoload.php';
13+
return function (array $context) {
14+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
1615

17-
if (!class_exists(Application::class)) {
18-
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
19-
}
20-
21-
$input = new ArgvInput();
22-
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
23-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
24-
}
25-
26-
if ($input->hasParameterOption('--no-debug', true)) {
27-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
28-
}
29-
30-
require dirname(__DIR__).'/config/bootstrap.php';
31-
32-
if ($_SERVER['APP_DEBUG']) {
33-
umask(0000);
34-
35-
if (class_exists(Debug::class)) {
36-
Debug::enable();
37-
}
38-
}
39-
40-
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
41-
$application = new Application($kernel);
42-
$application->run($input);
16+
return new Application($kernel);
17+
};

composer.json

+13-8
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,25 @@
99
"doctrine/doctrine-bundle": "2.5.*",
1010
"doctrine/doctrine-migrations-bundle": "3.2.*",
1111
"doctrine/orm": "2.11.*",
12-
"symfony/console": "5.4.*",
13-
"symfony/dotenv": "5.4.*",
12+
"symfony/console": "6.1.*",
13+
"symfony/dotenv": "6.1.*",
1414
"symfony/flex": "^1.3.1",
15-
"symfony/framework-bundle": "5.4.*",
16-
"symfony/yaml": "5.4.*"
15+
"symfony/framework-bundle": "6.1.*",
16+
"symfony/runtime": "6.1.*",
17+
"symfony/yaml": "6.1.*"
1718
},
1819
"require-dev": {
19-
"symfony/maker-bundle": "^1.14"
20+
"symfony/maker-bundle": "1.43.*"
2021
},
2122
"config": {
2223
"preferred-install": {
2324
"*": "dist"
2425
},
25-
"sort-packages": true
26+
"sort-packages": true,
27+
"allow-plugins": {
28+
"symfony/flex": true,
29+
"symfony/runtime": true
30+
}
2631
},
2732
"autoload": {
2833
"psr-4": {
@@ -61,7 +66,7 @@
6166
"extra": {
6267
"symfony": {
6368
"allow-contrib": false,
64-
"require": "5.4.*"
69+
"require": "6.1.*"
6570
}
6671
}
67-
}
72+
}

0 commit comments

Comments
 (0)