From f9e7edab892f191fc7c4e5de145fbc53a3254da6 Mon Sep 17 00:00:00 2001
From: Julian PEREZ-RAMIREZ <julian.perez-ramirez@imt-atlantique.net>
Date: Wed, 19 Feb 2025 20:53:46 +0100
Subject: [PATCH] adding symfony skeleton project

---
 compose.yaml                           | 40 +++++++++------
 web_app/.env.dev                       |  4 ++
 web_app/.gitignore                     | 10 ++++
 web_app/bin/console                    | 21 ++++++++
 web_app/composer.json                  | 69 ++++++++++++++++++++++++++
 web_app/config/bundles.php             |  5 ++
 web_app/config/packages/cache.yaml     | 19 +++++++
 web_app/config/packages/framework.yaml | 15 ++++++
 web_app/config/packages/routing.yaml   | 10 ++++
 web_app/config/preload.php             |  5 ++
 web_app/config/routes.yaml             |  5 ++
 web_app/config/routes/framework.yaml   |  4 ++
 web_app/config/services.yaml           | 24 +++++++++
 web_app/public/index.php               |  9 ++++
 web_app/src/Controller/.gitignore      |  0
 web_app/src/Kernel.php                 | 11 ++++
 web_app/symfony.lock                   | 59 ++++++++++++++++++++++
 17 files changed, 295 insertions(+), 15 deletions(-)
 create mode 100644 web_app/.env.dev
 create mode 100644 web_app/.gitignore
 create mode 100755 web_app/bin/console
 create mode 100644 web_app/composer.json
 create mode 100644 web_app/config/bundles.php
 create mode 100644 web_app/config/packages/cache.yaml
 create mode 100644 web_app/config/packages/framework.yaml
 create mode 100644 web_app/config/packages/routing.yaml
 create mode 100644 web_app/config/preload.php
 create mode 100644 web_app/config/routes.yaml
 create mode 100644 web_app/config/routes/framework.yaml
 create mode 100644 web_app/config/services.yaml
 create mode 100644 web_app/public/index.php
 create mode 100644 web_app/src/Controller/.gitignore
 create mode 100644 web_app/src/Kernel.php
 create mode 100644 web_app/symfony.lock

diff --git a/compose.yaml b/compose.yaml
index f10b51b..23100aa 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 0000000..98485ae
--- /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 0000000..a67f91e
--- /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 0000000..d8d530e
--- /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 0000000..d51a94e
--- /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 0000000..49d3fb6
--- /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 0000000..6899b72
--- /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 0000000..7e1ee1f
--- /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 0000000..8166181
--- /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 0000000..5ebcdb2
--- /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 0000000..41ef814
--- /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 0000000..0fc74bb
--- /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 0000000..2d6a76f
--- /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 0000000..9982c21
--- /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 0000000..e69de29
diff --git a/web_app/src/Kernel.php b/web_app/src/Kernel.php
new file mode 100644
index 0000000..779cd1f
--- /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 0000000..8ca246f
--- /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"
+        ]
+    }
+}
-- 
GitLab