diff --git a/.gitignore b/.gitignore index 7b64898..501704b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,14 @@ vendor .php_cs.cache composer.lock -var \ No newline at end of file +var + +###> symfony/framework-bundle ### +/.env.local +/.env.local.php +/.env.*.local +/Drift/config/secrets/prod/prod.decrypt.private.php +/public/bundles/ +/var/ +/vendor/ +###< symfony/framework-bundle ### diff --git a/Drift/Kernel.php b/Drift/Kernel.php index 46347f9..c24a7cd 100644 --- a/Drift/Kernel.php +++ b/Drift/Kernel.php @@ -29,6 +29,8 @@ class Kernel extends AsyncKernel { use MicroKernelTrait; + private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; + /** * @return iterable */ @@ -68,7 +70,12 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa { $confDir = $this->getApplicationLayerDir().'/config'; $container->setParameter('container.dumper.inline_class_loader', true); - $loader->load($confDir.'/services.yml'); + $container->setParameter('container.dumper.inline_factories', true); + + $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); } /** @@ -79,6 +86,9 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa protected function configureRoutes(RouteCollectionBuilder $routes): void { $confDir = $this->getApplicationLayerDir().'/config'; - $routes->import($confDir.'/routes.yml'); + + $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); } } diff --git a/Drift/config/bootstrap.php b/Drift/config/bootstrap.php index 0863275..47f624d 100644 --- a/Drift/config/bootstrap.php +++ b/Drift/config/bootstrap.php @@ -15,7 +15,7 @@ use Symfony\Component\Dotenv\Dotenv; -$appDir = dirname(__FILE__).'/../..'; +$appDir = __DIR__ .'/../..'; require $appDir.'/vendor/autoload.php'; if (is_file($appDir.'/.env')) { diff --git a/Drift/config/packages/driftphp.yaml b/Drift/config/packages/driftphp.yaml new file mode 100644 index 0000000..45f085d --- /dev/null +++ b/Drift/config/packages/driftphp.yaml @@ -0,0 +1,14 @@ +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. + + Domain\: + resource: "%kernel.project_dir%/src/Domain/*" + + Infrastructure\: + resource: "%kernel.project_dir%/src/Infrastructure/*" + diff --git a/Drift/config/packages/framework.yaml b/Drift/config/packages/framework.yaml new file mode 100644 index 0000000..bbfe2da --- /dev/null +++ b/Drift/config/packages/framework.yaml @@ -0,0 +1,8 @@ +framework: + secret: '%env(APP_SECRET)%' + form: false + assets: false + session: false + translator: false + php_errors: + log: false diff --git a/Drift/config/packages/prod/routing.yaml b/Drift/config/packages/prod/routing.yaml new file mode 100644 index 0000000..b3e6a0a --- /dev/null +++ b/Drift/config/packages/prod/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: null diff --git a/Drift/config/packages/routing.yaml b/Drift/config/packages/routing.yaml new file mode 100644 index 0000000..7e97762 --- /dev/null +++ b/Drift/config/packages/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + utf8: true diff --git a/Drift/config/packages/test/framework.yaml b/Drift/config/packages/test/framework.yaml new file mode 100644 index 0000000..f76cc2e --- /dev/null +++ b/Drift/config/packages/test/framework.yaml @@ -0,0 +1,2 @@ +framework: + test: true diff --git a/Drift/config/routes.yml b/Drift/config/routes.yaml similarity index 100% rename from Drift/config/routes.yml rename to Drift/config/routes.yaml diff --git a/Drift/config/routes/.gitignore b/Drift/config/routes/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Drift/config/services.yaml b/Drift/config/services.yaml new file mode 100644 index 0000000..9263875 --- /dev/null +++ b/Drift/config/services.yaml @@ -0,0 +1,20 @@ +parameters: + app_path: "../.." + +# config/services.yaml +services: + _defaults: + autowire: true + autoconfigure: true + + App\: + resource: '%kernel.project_dir%/src/*' + exclude: '%kernel.project_dir%/src/{DependencyInjection,Entity,Migrations,Tests}' + # + # If you want to provide HTTP Endpoints, include the following part to enable service argument injection + # and make controllers public. + # +# App\Controller\: +# resource : "%kernel.project_dir%/src/Controller/*" +# tags: +# - {name: controller.service_arguments} diff --git a/Drift/config/services.yml b/Drift/config/services.yml deleted file mode 100644 index 801a89d..0000000 --- a/Drift/config/services.yml +++ /dev/null @@ -1,26 +0,0 @@ -parameters: - kernel.secret: yoursecretshouldbehere - app_path: "../.." - -framework: - form: false - assets: false - session: false - translator: false - php_errors: - log: false - -# config/services.yaml -services: - _defaults: - autowire: true - autoconfigure: true - public: true - - # - # Controllers - # - App\Controller\: - resource : "%app_path%/src/Controller/*" - tags: - - {name: controller.service_arguments} \ No newline at end of file diff --git a/composer.json b/composer.json index 9889a64..ad736d6 100644 --- a/composer.json +++ b/composer.json @@ -1,33 +1,41 @@ { - "name": "drift/skeleton", - "description": "Skeleton repository ofr DriftPHP", - "type": "project", - "license": "MIT", - "authors": [ - { - "name": "Marc Morera", - "email": "yuhu@mmoreram.com" - } - ], - "require": { - "php": "^7.3", - "symfony/console": "^5.0.0", - "symfony/framework-bundle": "^5.0.0", - "symfony/dotenv": "^5.0.0", - "symfony/stopwatch": "^5.0.0", - "symfony/debug": "^4.4.0", - - "drift/http-kernel": "0.1.*, >=0.1.7", - "drift/server": "0.1.*, >=0.1.7", - "drift/react-functions": "0.1.*", - "drift/event-loop-utils": "0.1.*" - }, - "autoload": { - "psr-4": { - "App\\": "src/", - "Domain\\": "src/Domain", - "Infrastructure\\": "src", - "Drift\\": "Drift/" - } + "name": "drift/skeleton", + "description": "Skeleton repository ofr DriftPHP", + "type": "project", + "license": "MIT", + "authors": [ + { + "name": "Marc Morera", + "email": "yuhu@mmoreram.com" } -} \ No newline at end of file + ], + "require": { + "php": "^7.3", + "symfony/console": "^5.0.0", + "symfony/framework-bundle": "^5.0.0", + "symfony/dotenv": "^5.0.0", + "symfony/stopwatch": "^5.0.0", + "symfony/debug": "^4.4.0", + "drift/http-kernel": "0.1.*, >=0.1.7", + "drift/server": "0.1.*, >=0.1.7", + "drift/react-functions": "0.1.*", + "drift/event-loop-utils": "0.1.*", + "symfony/flex": "^1.8" + }, + "autoload": { + "psr-4": { + "App\\": "src/", + "Domain\\": "src/Domain", + "Infrastructure\\": "src/Infrastructure", + "Drift\\": "Drift/" + } + }, + "scripts": { + "server": "server run 0.0.0.0:8000", + "watcher": "server watch 0.0.0.0:8000 --debug --env=dev" + }, + "extra": { + "src-dir": "Drift", + "config-dir": "Drift/config" + } +} diff --git a/composer.lock b/composer.lock index 7d7ad3e..b295d25 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "63f20fe6102d530d75bdf7b16cfb4b94", + "content-hash": "bd2067d1fd0e68b42a29d309e5bbe9c2", "packages": [ { "name": "alecrabbit/php-cli-snake", @@ -2340,6 +2340,55 @@ "homepage": "https://symfony.com", "time": "2020-02-14T07:43:07+00:00" }, + { + "name": "symfony/flex", + "version": "v1.8.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/flex.git", + "reference": "7df5a72c7664baab629ec33de7890e9e3996b51b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/flex/zipball/7df5a72c7664baab629ec33de7890e9e3996b51b", + "reference": "7df5a72c7664baab629ec33de7890e9e3996b51b", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": ">=7.1" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "symfony/dotenv": "^4.4|^5.0", + "symfony/phpunit-bridge": "^4.4|^5.0", + "symfony/process": "^3.4|^4.4|^5.0" + }, + "type": "composer-plugin", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + }, + "class": "Symfony\\Flex\\Flex" + }, + "autoload": { + "psr-4": { + "Symfony\\Flex\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" + } + ], + "description": "Composer plugin for Symfony", + "time": "2020-06-16T23:10:41+00:00" + }, { "name": "symfony/framework-bundle", "version": "v5.0.5", diff --git a/src/Infrastructure/.gitignore b/src/Infrastructure/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/symfony.lock b/symfony.lock new file mode 100644 index 0000000..fd4f1e6 --- /dev/null +++ b/symfony.lock @@ -0,0 +1,262 @@ +{ + "alecrabbit/php-cli-snake": { + "version": "0.5.0" + }, + "cakephp/core": { + "version": "3.8.10" + }, + "cakephp/utility": { + "version": "3.8.10" + }, + "clue/block-react": { + "version": "v1.3.1" + }, + "doctrine/inflector": { + "version": "1.3.1" + }, + "doctrine/instantiator": { + "version": "1.3.0" + }, + "drift/console-bridge": { + "version": "0.1.0" + }, + "drift/event-loop-utils": { + "version": "0.1.0" + }, + "drift/http-kernel": { + "version": "0.1.9" + }, + "drift/react-functions": { + "version": "0.1.0" + }, + "drift/server": { + "version": "0.1.7" + }, + "evenement/evenement": { + "version": "v3.0.1" + }, + "indigophp/hash-compat": { + "version": "v1.1.0" + }, + "paragonie/random_compat": { + "version": "v9.99.99" + }, + "php": { + "version": "7.4" + }, + "psr/cache": { + "version": "1.0.1" + }, + "psr/container": { + "version": "1.0.0" + }, + "psr/event-dispatcher": { + "version": "1.0.0" + }, + "psr/http-message": { + "version": "1.0.1" + }, + "psr/log": { + "version": "1.1.3" + }, + "react/cache": { + "version": "v1.0.0" + }, + "react/child-process": { + "version": "v0.6.1" + }, + "react/dns": { + "version": "v1.2.0" + }, + "react/event-loop": { + "version": "v1.1.1" + }, + "react/filesystem": { + "version": "v0.1.2" + }, + "react/http": { + "version": "v0.8.6" + }, + "react/promise": { + "version": "v2.7.1" + }, + "react/promise-stream": { + "version": "v1.2.0" + }, + "react/promise-timer": { + "version": "v1.5.1" + }, + "react/socket": { + "version": "v1.4.0" + }, + "react/stream": { + "version": "v1.1.0" + }, + "ringcentral/psr7": { + "version": "1.2.2" + }, + "seregazhuk/php-watcher": { + "version": "v0.5.2" + }, + "symfony/cache": { + "version": "v5.0.5" + }, + "symfony/cache-contracts": { + "version": "v2.0.1" + }, + "symfony/config": { + "version": "v5.0.5" + }, + "symfony/console": { + "version": "4.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "4.4", + "ref": "ea8c0eda34fda57e7d5cd8cbd889e2a387e3472c" + }, + "files": [ + "bin/console", + "Drift/config/bootstrap.php" + ] + }, + "symfony/debug": { + "version": "v4.4.5" + }, + "symfony/dependency-injection": { + "version": "v5.0.5" + }, + "symfony/dotenv": { + "version": "v5.0.5" + }, + "symfony/error-handler": { + "version": "v5.0.5" + }, + "symfony/event-dispatcher": { + "version": "v5.0.5" + }, + "symfony/event-dispatcher-contracts": { + "version": "v2.0.1" + }, + "symfony/filesystem": { + "version": "v5.0.5" + }, + "symfony/finder": { + "version": "v5.0.5" + }, + "symfony/flex": { + "version": "1.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "1.0", + "ref": "c0eeb50665f0f77226616b6038a9b06c03752d8e" + }, + "files": [ + ".env" + ] + }, + "symfony/framework-bundle": { + "version": "4.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "4.4", + "ref": "36d3075b2b8e0c4de0e82356a86e4c4a4eb6681b" + }, + "files": [ + "Drift/config/bootstrap.php", + "Drift/config/packages/cache.yaml", + "Drift/config/packages/framework.yaml", + "Drift/config/packages/test/framework.yaml", + "Drift/config/routes/dev/framework.yaml", + "Drift/config/services.yaml", + "public/index.php", + "Drift/Controller/.gitignore", + "Drift/Kernel.php" + ] + }, + "symfony/http-foundation": { + "version": "v5.0.5" + }, + "symfony/http-kernel": { + "version": "v5.0.5" + }, + "symfony/mime": { + "version": "v5.0.5" + }, + "symfony/polyfill-ctype": { + "version": "v1.15.0" + }, + "symfony/polyfill-intl-idn": { + "version": "v1.15.0" + }, + "symfony/polyfill-mbstring": { + "version": "v1.15.0" + }, + "symfony/polyfill-php72": { + "version": "v1.15.0" + }, + "symfony/polyfill-php73": { + "version": "v1.15.0" + }, + "symfony/routing": { + "version": "4.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "4.2", + "ref": "683dcb08707ba8d41b7e34adb0344bfd68d248a7" + }, + "files": [ + "Drift/config/packages/prod/routing.yaml", + "Drift/config/packages/routing.yaml", + "Drift/config/routes.yaml" + ] + }, + "symfony/service-contracts": { + "version": "v2.0.1" + }, + "symfony/stopwatch": { + "version": "v5.0.5" + }, + "symfony/var-dumper": { + "version": "v5.0.5" + }, + "symfony/var-exporter": { + "version": "v5.0.5" + }, + "symfony/yaml": { + "version": "v5.0.5" + }, + "tivie/php-os-detector": { + "version": "1.1.0" + }, + "wyrihaximus/cpu-core-detector": { + "version": "1.0.2" + }, + "wyrihaximus/file-descriptors": { + "version": "1.0.0" + }, + "wyrihaximus/json-throwable": { + "version": "2.0.0" + }, + "wyrihaximus/json-utilities": { + "version": "1.1.0" + }, + "wyrihaximus/react-child-process-messenger": { + "version": "2.10.0" + }, + "wyrihaximus/react-child-process-pool": { + "version": "1.6.0" + }, + "wyrihaximus/react-child-process-promise": { + "version": "2.0.2" + }, + "wyrihaximus/ticking-promise": { + "version": "1.6.3" + }, + "yosymfony/resource-watcher": { + "version": "v2.0.1" + } +}