diff --git a/compose.yaml b/compose.yaml index f10b51be3bfd89b77656bc9dda5c8a961f259eec..23100aa8e484350a7eb27f66758b2e4bafaa4ddd 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,27 +1,37 @@ services: - web: - image: php:8.2-apache #check the php version you need for your project - container_name: apache_server + symfony: + image: bitnami/symfony + container_name: symfony_app ports: - - "80:80" #this line maps your pc port to the container port - depends_on: - - db #this line links this container to the db container + - "80:8000" + environment: + - SYMFONY_PROJECT_SKELETON=symfony/skeleton + - DATABASE_HOST=mysql + - SYMFONY_DATABASE_PASSWORD=symfony volumes: - - ./www:/var/www/html #this line maps the content of ./html in your pc to the /var/www/html of the container - db: - image: mysql:8.1.0 #check the mysql version you need for your project - container_name: mysql_db + - ./web_app:/app + depends_on: + - mysql + + mysql: + image: mysql:8.1 + container_name: symfony_db environment: - MYSQL_ROOT_PASSWORD: password #you can change the mysql root password here - MYSQL_DATABASE: lamp_db #you can change the database name here + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: symfony + MYSQL_USER: symfony + MYSQL_PASSWORD: symfony + ports: + - "3306:3306" volumes: - - ./mysql_data:/var/lib/mysql #this line maps the content of ./mysql_data in your pc to the /var/lib/mysql of the container + - ./mysql_data:/var/lib/mysql + phpmyadmin: image: phpmyadmin/phpmyadmin container_name: phpmyadmin ports: - "8080:80" #this line maps your pc port to the container port depends_on: - - db #this line links this container to the db container + - mysql #this line links this container to the db container environment: - PMA_HOST: db + PMA_HOST: mysql \ No newline at end of file diff --git a/web_app/.env.dev b/web_app/.env.dev new file mode 100644 index 0000000000000000000000000000000000000000..98485ae45be61c173a3e6fda85046f1f1bf37ae6 --- /dev/null +++ b/web_app/.env.dev @@ -0,0 +1,4 @@ + +###> symfony/framework-bundle ### +APP_SECRET=5b91d9c00db21a1d640377b21cc0e39d +###< symfony/framework-bundle ### diff --git a/web_app/.gitignore b/web_app/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a67f91e25c268247e2034877873a2b27f37619f0 --- /dev/null +++ b/web_app/.gitignore @@ -0,0 +1,10 @@ + +###> symfony/framework-bundle ### +/.env.local +/.env.local.php +/.env.*.local +/config/secrets/prod/prod.decrypt.private.php +/public/bundles/ +/var/ +/vendor/ +###< symfony/framework-bundle ### diff --git a/web_app/bin/console b/web_app/bin/console new file mode 100755 index 0000000000000000000000000000000000000000..d8d530e2c36a68f7916acdfa16c9afafcad06bf0 --- /dev/null +++ b/web_app/bin/console @@ -0,0 +1,21 @@ +#!/usr/bin/env php +<?php + +use App\Kernel; +use Symfony\Bundle\FrameworkBundle\Console\Application; + +if (!is_dir(dirname(__DIR__).'/vendor')) { + throw new LogicException('Dependencies are missing. Try running "composer install".'); +} + +if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { + throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); +} + +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; + +return function (array $context) { + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); + + return new Application($kernel); +}; diff --git a/web_app/composer.json b/web_app/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..d51a94e10d474a6e66a32a3f80bd7fcfc8777520 --- /dev/null +++ b/web_app/composer.json @@ -0,0 +1,69 @@ +{ + "type": "project", + "license": "proprietary", + "minimum-stability": "stable", + "prefer-stable": true, + "require": { + "php": ">=8.2", + "ext-ctype": "*", + "ext-iconv": "*", + "symfony/console": "7.2.*", + "symfony/dotenv": "7.2.*", + "symfony/flex": "^2", + "symfony/framework-bundle": "7.2.*", + "symfony/runtime": "7.2.*", + "symfony/yaml": "7.2.*" + }, + "require-dev": { + }, + "config": { + "allow-plugins": { + "php-http/discovery": true, + "symfony/flex": true, + "symfony/runtime": true + }, + "bump-after-update": true, + "sort-packages": true + }, + "autoload": { + "psr-4": { + "App\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "App\\Tests\\": "tests/" + } + }, + "replace": { + "symfony/polyfill-ctype": "*", + "symfony/polyfill-iconv": "*", + "symfony/polyfill-php72": "*", + "symfony/polyfill-php73": "*", + "symfony/polyfill-php74": "*", + "symfony/polyfill-php80": "*", + "symfony/polyfill-php81": "*", + "symfony/polyfill-php82": "*" + }, + "scripts": { + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" + }, + "post-install-cmd": [ + "@auto-scripts" + ], + "post-update-cmd": [ + "@auto-scripts" + ] + }, + "conflict": { + "symfony/symfony": "*" + }, + "extra": { + "symfony": { + "allow-contrib": false, + "require": "7.2.*" + } + } +} diff --git a/web_app/config/bundles.php b/web_app/config/bundles.php new file mode 100644 index 0000000000000000000000000000000000000000..49d3fb6fcef0acfd0f1d4920a71806ca22a69942 --- /dev/null +++ b/web_app/config/bundles.php @@ -0,0 +1,5 @@ +<?php + +return [ + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], +]; diff --git a/web_app/config/packages/cache.yaml b/web_app/config/packages/cache.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6899b72003fca67f5a56b945cd3e07f5c8a33774 --- /dev/null +++ b/web_app/config/packages/cache.yaml @@ -0,0 +1,19 @@ +framework: + cache: + # Unique name of your app: used to compute stable namespaces for cache keys. + #prefix_seed: your_vendor_name/app_name + + # The "app" cache stores to the filesystem by default. + # The data in this cache should persist between deploys. + # Other options include: + + # Redis + #app: cache.adapter.redis + #default_redis_provider: redis://localhost + + # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) + #app: cache.adapter.apcu + + # Namespaced pools use the above "app" backend by default + #pools: + #my.dedicated.cache: null diff --git a/web_app/config/packages/framework.yaml b/web_app/config/packages/framework.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7e1ee1f1e0d1183963de0d822c064178a2c4422c --- /dev/null +++ b/web_app/config/packages/framework.yaml @@ -0,0 +1,15 @@ +# see https://symfony.com/doc/current/reference/configuration/framework.html +framework: + secret: '%env(APP_SECRET)%' + + # Note that the session will be started ONLY if you read or write from it. + session: true + + #esi: true + #fragments: true + +when@test: + framework: + test: true + session: + storage_factory_id: session.storage.factory.mock_file diff --git a/web_app/config/packages/routing.yaml b/web_app/config/packages/routing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8166181c68ab07bfac9aee6e482c7cc24031b8aa --- /dev/null +++ b/web_app/config/packages/routing.yaml @@ -0,0 +1,10 @@ +framework: + router: + # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. + # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands + #default_uri: http://localhost + +when@prod: + framework: + router: + strict_requirements: null diff --git a/web_app/config/preload.php b/web_app/config/preload.php new file mode 100644 index 0000000000000000000000000000000000000000..5ebcdb2153c870e7d915f3b3fcdd55821424284c --- /dev/null +++ b/web_app/config/preload.php @@ -0,0 +1,5 @@ +<?php + +if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) { + require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php'; +} diff --git a/web_app/config/routes.yaml b/web_app/config/routes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..41ef8140ba811c0da46ce1962ffa50d4c56b9840 --- /dev/null +++ b/web_app/config/routes.yaml @@ -0,0 +1,5 @@ +controllers: + resource: + path: ../src/Controller/ + namespace: App\Controller + type: attribute diff --git a/web_app/config/routes/framework.yaml b/web_app/config/routes/framework.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0fc74bbac4b757dd49782f0be496f6fd7e07e47c --- /dev/null +++ b/web_app/config/routes/framework.yaml @@ -0,0 +1,4 @@ +when@dev: + _errors: + resource: '@FrameworkBundle/Resources/config/routing/errors.xml' + prefix: /_error diff --git a/web_app/config/services.yaml b/web_app/config/services.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2d6a76f94dce138741e2d63ae83a11c1879031d9 --- /dev/null +++ b/web_app/config/services.yaml @@ -0,0 +1,24 @@ +# This file is the entry point to configure your own services. +# Files in the packages/ subdirectory configure your dependencies. + +# Put parameters here that don't need to change on each machine where the app is deployed +# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration +parameters: + +services: + # default configuration for services in *this* file + _defaults: + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + + # makes classes in src/ available to be used as services + # this creates a service per class whose id is the fully-qualified class name + App\: + resource: '../src/' + exclude: + - '../src/DependencyInjection/' + - '../src/Entity/' + - '../src/Kernel.php' + + # add more service definitions when explicit configuration is needed + # please note that last definitions always *replace* previous ones diff --git a/web_app/public/index.php b/web_app/public/index.php new file mode 100644 index 0000000000000000000000000000000000000000..9982c218d6969c72d4c91e3834e3f535e2dfe68b --- /dev/null +++ b/web_app/public/index.php @@ -0,0 +1,9 @@ +<?php + +use App\Kernel; + +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; + +return function (array $context) { + return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); +}; diff --git a/web_app/src/Controller/.gitignore b/web_app/src/Controller/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/web_app/src/Kernel.php b/web_app/src/Kernel.php new file mode 100644 index 0000000000000000000000000000000000000000..779cd1f2b12e0d30731787539ba67645b73ef796 --- /dev/null +++ b/web_app/src/Kernel.php @@ -0,0 +1,11 @@ +<?php + +namespace App; + +use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Component\HttpKernel\Kernel as BaseKernel; + +class Kernel extends BaseKernel +{ + use MicroKernelTrait; +} diff --git a/web_app/symfony.lock b/web_app/symfony.lock new file mode 100644 index 0000000000000000000000000000000000000000..8ca246fee21fa0daf700c908c6514aaa67deaa94 --- /dev/null +++ b/web_app/symfony.lock @@ -0,0 +1,59 @@ +{ + "symfony/console": { + "version": "7.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "1781ff40d8a17d87cf53f8d4cf0c8346ed2bb461" + }, + "files": [ + "bin/console" + ] + }, + "symfony/flex": { + "version": "2.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.4", + "ref": "52e9754527a15e2b79d9a610f98185a1fe46622a" + }, + "files": [ + ".env", + ".env.dev" + ] + }, + "symfony/framework-bundle": { + "version": "7.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "7.2", + "ref": "87bcf6f7c55201f345d8895deda46d2adbdbaa89" + }, + "files": [ + "config/packages/cache.yaml", + "config/packages/framework.yaml", + "config/preload.php", + "config/routes/framework.yaml", + "config/services.yaml", + "public/index.php", + "src/Controller/.gitignore", + "src/Kernel.php" + ] + }, + "symfony/routing": { + "version": "7.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "7.0", + "ref": "21b72649d5622d8f7da329ffb5afb232a023619d" + }, + "files": [ + "config/packages/routing.yaml", + "config/routes.yaml" + ] + } +}