diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..72f18abcba2fe7730a2ba016d87a4ea821f515b9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM bitnami/symfony:latest + +WORKDIR /app + +COPY . /app + +# Ensure dependencies are installed +RUN composer install --no-interaction --prefer-dist --optimize-autoloader + +# Install Doctrine ORM explicitly +RUN composer require symfony/orm-pack --no-scripts --no-interactio + +EXPOSE 8000 diff --git a/compose.yaml b/compose.yaml index 23100aa8e484350a7eb27f66758b2e4bafaa4ddd..f86b3c8ad50293d8108030887a07dcb79fcb1dba 100644 --- a/compose.yaml +++ b/compose.yaml @@ -17,8 +17,8 @@ services: image: mysql:8.1 container_name: symfony_db environment: - MYSQL_ROOT_PASSWORD: rootpassword - MYSQL_DATABASE: symfony + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: wishlist_db MYSQL_USER: symfony MYSQL_PASSWORD: symfony ports: @@ -34,4 +34,7 @@ services: depends_on: - mysql #this line links this container to the db container environment: - PMA_HOST: mysql \ No newline at end of file + PMA_HOST: mysql + +#If you got an error about folder permissions with innodb_redo, +# try to fix it by running sudo chmod -R 755 ~/<your_path>/wishlist/mysql_data \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..6da41e572a70b9fb0546b5c30a77d9dbf1d66982 --- /dev/null +++ b/composer.json @@ -0,0 +1,8 @@ +{ + "require": { + "symfony/orm-pack": "^2.4" + }, + "require-dev": { + "symfony/maker-bundle": "^1.62" + } +} diff --git a/web_app/compose.override.yaml b/web_app/compose.override.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c5612b0ad1957ade3aeb03176f49da20cda51469 --- /dev/null +++ b/web_app/compose.override.yaml @@ -0,0 +1,7 @@ + +services: +###> doctrine/doctrine-bundle ### + database: + ports: + - "5432" +###< doctrine/doctrine-bundle ### diff --git a/web_app/compose.yaml b/web_app/compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..89c74d180dbc0c7256caa190444cbb7c4036dca5 --- /dev/null +++ b/web_app/compose.yaml @@ -0,0 +1,25 @@ + +services: +###> doctrine/doctrine-bundle ### + database: + image: postgres:${POSTGRES_VERSION:-16}-alpine + environment: + POSTGRES_DB: ${POSTGRES_DB:-app} + # You should definitely change the password in production + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!} + POSTGRES_USER: ${POSTGRES_USER:-app} + healthcheck: + test: ["CMD", "pg_isready", "-d", "${POSTGRES_DB:-app}", "-U", "${POSTGRES_USER:-app}"] + timeout: 5s + retries: 5 + start_period: 60s + volumes: + - database_data:/var/lib/postgresql/data:rw + # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! + # - ./docker/db/data:/var/lib/postgresql/data:rw +###< doctrine/doctrine-bundle ### + +volumes: +###> doctrine/doctrine-bundle ### + database_data: +###< doctrine/doctrine-bundle ### diff --git a/web_app/composer.json b/web_app/composer.json index d51a94e10d474a6e66a32a3f80bd7fcfc8777520..bc22af86027131fbc897a33022d6d7fb4824a55f 100644 --- a/web_app/composer.json +++ b/web_app/composer.json @@ -7,6 +7,10 @@ "php": ">=8.2", "ext-ctype": "*", "ext-iconv": "*", + "doctrine/dbal": "^3", + "doctrine/doctrine-bundle": "^2.13", + "doctrine/doctrine-migrations-bundle": "^3.4", + "doctrine/orm": "^3.3", "symfony/console": "7.2.*", "symfony/dotenv": "7.2.*", "symfony/flex": "^2", @@ -14,8 +18,6 @@ "symfony/runtime": "7.2.*", "symfony/yaml": "7.2.*" }, - "require-dev": { - }, "config": { "allow-plugins": { "php-http/discovery": true, diff --git a/web_app/config/bundles.php b/web_app/config/bundles.php index 49d3fb6fcef0acfd0f1d4920a71806ca22a69942..c1fa06a6a1872365a0051751113af90dcc47c227 100644 --- a/web_app/config/bundles.php +++ b/web_app/config/bundles.php @@ -2,4 +2,6 @@ return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], ]; diff --git a/web_app/config/packages/doctrine.yaml b/web_app/config/packages/doctrine.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25138b979b685a90e7abcc8dbc563d5a5896683b --- /dev/null +++ b/web_app/config/packages/doctrine.yaml @@ -0,0 +1,54 @@ +doctrine: + dbal: + url: '%env(resolve:DATABASE_URL)%' + + # IMPORTANT: You MUST configure your server version, + # either here or in the DATABASE_URL env var (see .env file) + #server_version: '16' + + profiling_collect_backtrace: '%kernel.debug%' + use_savepoints: true + orm: + auto_generate_proxy_classes: true + enable_lazy_ghost_objects: true + report_fields_where_declared: true + validate_xml_mapping: true + naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware + identity_generation_preferences: + Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity + auto_mapping: true + mappings: + App: + type: attribute + is_bundle: false + dir: '%kernel.project_dir%/src/Entity' + prefix: 'App\Entity' + alias: App + controller_resolver: + auto_mapping: false + +when@test: + doctrine: + dbal: + # "TEST_TOKEN" is typically set by ParaTest + dbname_suffix: '_test%env(default::TEST_TOKEN)%' + +when@prod: + doctrine: + orm: + auto_generate_proxy_classes: false + proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies' + query_cache_driver: + type: pool + pool: doctrine.system_cache_pool + result_cache_driver: + type: pool + pool: doctrine.result_cache_pool + + framework: + cache: + pools: + doctrine.result_cache_pool: + adapter: cache.app + doctrine.system_cache_pool: + adapter: cache.system diff --git a/web_app/config/packages/doctrine_migrations.yaml b/web_app/config/packages/doctrine_migrations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..29231d94bd1afd6f35b3c1e64687640d3f1e2f50 --- /dev/null +++ b/web_app/config/packages/doctrine_migrations.yaml @@ -0,0 +1,6 @@ +doctrine_migrations: + migrations_paths: + # namespace is arbitrary but should be different from App\Migrations + # as migrations classes should NOT be autoloaded + 'DoctrineMigrations': '%kernel.project_dir%/migrations' + enable_profiler: false diff --git a/web_app/migrations/.gitignore b/web_app/migrations/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/web_app/src/Entity/.gitignore b/web_app/src/Entity/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/web_app/src/Repository/.gitignore b/web_app/src/Repository/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/web_app/symfony.lock b/web_app/symfony.lock index 8ca246fee21fa0daf700c908c6514aaa67deaa94..bb5af909aed2128d74d60f4d2de087cd724446e7 100644 --- a/web_app/symfony.lock +++ b/web_app/symfony.lock @@ -1,4 +1,31 @@ { + "doctrine/doctrine-bundle": { + "version": "2.13", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.13", + "ref": "8d96c0b51591ffc26794d865ba3ee7d193438a83" + }, + "files": [ + "config/packages/doctrine.yaml", + "src/Entity/.gitignore", + "src/Repository/.gitignore" + ] + }, + "doctrine/doctrine-migrations-bundle": { + "version": "3.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.1", + "ref": "1d01ec03c6ecbd67c3375c5478c9a423ae5d6a33" + }, + "files": [ + "config/packages/doctrine_migrations.yaml", + "migrations/.gitignore" + ] + }, "symfony/console": { "version": "7.2", "recipe": {