diff --git a/.env b/.env index 2c5fda79..1550c0b6 100644 --- a/.env +++ b/.env @@ -18,3 +18,13 @@ APP_ENV=dev APP_SECRET=28de35e787e86cb435f0312627623283 ###< symfony/framework-bundle ### + +###> doctrine/doctrine-bundle ### +# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml +# +# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" +# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" +# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" +DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" +###< doctrine/doctrine-bundle ### diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b4aab8d4..e9a6f9a6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,5 +70,14 @@ jobs: - name: Run PHPUnit run: vendor/bin/phpunit + - name: "Restrict packages' versions" + run: | + (cd src/TwigHooks/ && composer global config --no-plugins allow-plugins.symfony/flex true) + (cd src/TwigHooks/ && composer global require --no-progress --no-scripts --no-plugins "symfony/flex") + (cd src/TwigHooks/ && composer config extra.symfony.require "${{ matrix.symfony }}") + + - name: "Install dependencies (Twig Hooks)" + run: (cd src/TwigHooks/ && composer update --no-interaction --no-scripts) + - name: Run PHPUnit (Twig Hooks) - run: vendor/bin/phpunit -c src/TwigHooks/phpunit.xml.dist + run: (cd src/TwigHooks/ && vendor/bin/phpunit) diff --git a/app/Entity/.gitignore b/app/Entity/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/app/Repository/.gitignore b/app/Repository/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/compose.override.yaml b/compose.override.yaml new file mode 100644 index 00000000..12c777f2 --- /dev/null +++ b/compose.override.yaml @@ -0,0 +1,6 @@ +services: +###> doctrine/doctrine-bundle ### + database: + ports: + - "5432:5432" +###< doctrine/doctrine-bundle ### diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..724e9802 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,19 @@ +services: +###> doctrine/doctrine-bundle ### + database: + image: postgres:${POSTGRES_VERSION:-16}-alpine + environment: + POSTGRES_DB: ${POSTGRES_DB:-sylius_stack} + # You should definitely change the password in production + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-sylius_stack} + POSTGRES_USER: ${POSTGRES_USER:-sylius_stack} + 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/composer.json b/composer.json index 452c275f..acbdd8df 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,12 @@ ], "require": { "php": "^8.1", + "doctrine/dbal": "^3", + "doctrine/doctrine-bundle": "^2.12", + "doctrine/doctrine-migrations-bundle": "^3.3", + "doctrine/orm": "^2.0", "laminas/laminas-stdlib": "^3.18", + "sylius/resource-bundle": "dev-symfony-7", "symfony/config": "^6.4 || ^7.0", "symfony/dependency-injection": "^6.4 || ^7.0", "symfony/expression-language": "^6.4 || ^7.0", diff --git a/config/bundles.php b/config/bundles.php index b7364282..9ee0ae17 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -9,4 +9,9 @@ Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true], + winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], + Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], ]; diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml new file mode 100644 index 00000000..014612d5 --- /dev/null +++ b/config/packages/doctrine.yaml @@ -0,0 +1,50 @@ +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 + auto_mapping: true + mappings: + App: + type: attribute + is_bundle: false + dir: '%kernel.project_dir%/app/Entity' + prefix: 'App\Entity' + alias: App + +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/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml new file mode 100644 index 00000000..29231d94 --- /dev/null +++ b/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/config/packages/sylius_resource.yaml b/config/packages/sylius_resource.yaml new file mode 100644 index 00000000..9f33b60b --- /dev/null +++ b/config/packages/sylius_resource.yaml @@ -0,0 +1,15 @@ +# @see https://github.com/Sylius/SyliusResourceBundle/blob/master/docs/index.md +sylius_resource: + # Override default settings + #settings: + + # Configure the mapping for your resources + mapping: + paths: + - '%kernel.project_dir%/app/Entity' + + # Configure your resources + resources: + #app.book: + #classes: + #model: App\Entity\Book diff --git a/config/packages/validator.yaml b/config/packages/validator.yaml new file mode 100644 index 00000000..dd47a6ad --- /dev/null +++ b/config/packages/validator.yaml @@ -0,0 +1,11 @@ +framework: + validation: + # Enables validator auto-mapping support. + # For instance, basic validation constraints will be inferred from Doctrine's metadata. + #auto_mapping: + # App\Entity\: [] + +when@test: + framework: + validation: + not_compromised_password: false diff --git a/config/routes/sylius_resource.yaml b/config/routes/sylius_resource.yaml new file mode 100644 index 00000000..0c8ade2c --- /dev/null +++ b/config/routes/sylius_resource.yaml @@ -0,0 +1,7 @@ +sylius_crud_routes: + resource: 'sylius.routing.loader.crud_routes_attributes' + type: service + +sylius_routes: + resource: 'sylius.routing.loader.routes_attributes' + type: service diff --git a/migrations/.gitignore b/migrations/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/src/TwigHooks/tests/Functional/Twig/HookableTwigComponentTest.php b/src/TwigHooks/tests/Functional/Twig/HookableTwigComponentTest.php index bf57c7f0..b82e320a 100644 --- a/src/TwigHooks/tests/Functional/Twig/HookableTwigComponentTest.php +++ b/src/TwigHooks/tests/Functional/Twig/HookableTwigComponentTest.php @@ -14,6 +14,8 @@ final class HookableTwigComponentTest extends KernelTestCase { public function testItRendersHookableLiveComponentWithUsingTwigHooks(): void { + self::bootKernel(); + $this->assertSame( << diff --git a/symfony.lock b/symfony.lock index bd37c062..5d664988 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1,4 +1,43 @@ { + "babdev/pagerfanta-bundle": { + "version": "v4.4.0" + }, + "doctrine/annotations": { + "version": "2.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.10", + "ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05" + } + }, + "doctrine/doctrine-bundle": { + "version": "2.12", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.10", + "ref": "c170ded8fc587d6bd670550c43dafcf093762245" + }, + "files": [ + "config/packages/doctrine.yaml", + "src/Entity/.gitignore", + "src/Repository/.gitignore" + ] + }, + "doctrine/doctrine-migrations-bundle": { + "version": "3.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.1", + "ref": "1d01ec03c6ecbd67c3375c5478c9a423ae5d6a33" + }, + "files": [ + "config/packages/doctrine_migrations.yaml", + "migrations/.gitignore" + ] + }, "phpstan/phpstan": { "version": "1.10", "recipe": { @@ -22,6 +61,19 @@ "tests/bootstrap.php" ] }, + "sylius/resource-bundle": { + "version": "1.10", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.9", + "ref": "ee21c1fc90778f4b01c20e72c320cc34f8839c1e" + }, + "files": [ + "config/packages/sylius_resource.yaml", + "config/routes/sylius_resource.yaml" + ] + }, "symfony/console": { "version": "5.4", "recipe": { @@ -131,6 +183,18 @@ "symfony/ux-twig-component": { "version": "v2.12.0" }, + "symfony/validator": { + "version": "7.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "7.0", + "ref": "8c1c4e28d26a124b0bb273f537ca8ce443472bfd" + }, + "files": [ + "config/packages/validator.yaml" + ] + }, "symfony/web-profiler-bundle": { "version": "6.3", "recipe": { @@ -143,5 +207,8 @@ "config/packages/web_profiler.yaml", "config/routes/web_profiler.yaml" ] + }, + "winzou/state-machine-bundle": { + "version": "v0.6.2" } }