commit 73ec8832b7d05c61cd615c3854f4c74a211e8e2b Author: Simon Vieille Date: Wed Nov 11 13:17:58 2020 +0100 Add initial set of files diff --git a/.env b/.env new file mode 100644 index 0000000..c4142a2 --- /dev/null +++ b/.env @@ -0,0 +1,19 @@ +# In all environments, the following files are loaded if they exist, +# the latter taking precedence over the former: +# +# * .env contains default values for the environment variables needed by the app +# * .env.local uncommitted file with local overrides +# * .env.$APP_ENV committed environment-specific defaults +# * .env.$APP_ENV.local uncommitted environment-specific overrides +# +# Real environment variables win over .env files. +# +# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. +# +# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). +# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration + +###> symfony/framework-bundle ### +APP_ENV=dev +APP_SECRET=aa708f7c537a5c6d167229524aea0817 +###< symfony/framework-bundle ### diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a67f91e --- /dev/null +++ b/.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/bin/console b/bin/console new file mode 100755 index 0000000..8fe9d49 --- /dev/null +++ b/bin/console @@ -0,0 +1,43 @@ +#!/usr/bin/env php +getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); +} + +if ($input->hasParameterOption('--no-debug', true)) { + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); +} + +(new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); + +if ($_SERVER['APP_DEBUG']) { + umask(0000); + + if (class_exists(Debug::class)) { + Debug::enable(); + } +} + +$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); +$application = new Application($kernel); +$application->run($input); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a95524c --- /dev/null +++ b/composer.json @@ -0,0 +1,61 @@ +{ + "type": "project", + "license": "proprietary", + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=7.2.5", + "ext-ctype": "*", + "ext-iconv": "*", + "symfony/console": "5.2.*", + "symfony/dotenv": "5.2.*", + "symfony/flex": "^1.3.1", + "symfony/framework-bundle": "5.2.*", + "symfony/yaml": "5.2.*" + }, + "require-dev": { + }, + "config": { + "optimize-autoloader": true, + "preferred-install": { + "*": "dist" + }, + "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": "*" + }, + "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": "5.2.*" + } + } +} diff --git a/config/bundles.php b/config/bundles.php new file mode 100644 index 0000000..49d3fb6 --- /dev/null +++ b/config/bundles.php @@ -0,0 +1,5 @@ + ['all' => true], +]; diff --git a/config/packages/cache.yaml b/config/packages/cache.yaml new file mode 100644 index 0000000..6899b72 --- /dev/null +++ b/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/config/packages/framework.yaml b/config/packages/framework.yaml new file mode 100644 index 0000000..cad7f78 --- /dev/null +++ b/config/packages/framework.yaml @@ -0,0 +1,17 @@ +# see https://symfony.com/doc/current/reference/configuration/framework.html +framework: + secret: '%env(APP_SECRET)%' + #csrf_protection: true + #http_method_override: true + + # Enables session support. Note that the session will ONLY be started if you read or write from it. + # Remove or comment this section to explicitly disable session support. + session: + handler_id: null + cookie_secure: auto + cookie_samesite: lax + + #esi: true + #fragments: true + php_errors: + log: true diff --git a/config/packages/prod/routing.yaml b/config/packages/prod/routing.yaml new file mode 100644 index 0000000..b3e6a0a --- /dev/null +++ b/config/packages/prod/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: null diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml new file mode 100644 index 0000000..b45c1ce --- /dev/null +++ b/config/packages/routing.yaml @@ -0,0 +1,7 @@ +framework: + router: + utf8: true + + # 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 diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml new file mode 100644 index 0000000..d051c84 --- /dev/null +++ b/config/packages/test/framework.yaml @@ -0,0 +1,4 @@ +framework: + test: true + session: + storage_id: session.storage.mock_file diff --git a/config/preload.php b/config/preload.php new file mode 100644 index 0000000..5ebcdb2 --- /dev/null +++ b/config/preload.php @@ -0,0 +1,5 @@ +bootEnv(dirname(__DIR__).'/.env'); + +if ($_SERVER['APP_DEBUG']) { + umask(0000); + + Debug::enable(); +} + +$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); +$request = Request::createFromGlobals(); +$response = $kernel->handle($request); +$response->send(); +$kernel->terminate($request, $response); diff --git a/src/Controller/.gitignore b/src/Controller/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/Kernel.php b/src/Kernel.php new file mode 100644 index 0000000..655e796 --- /dev/null +++ b/src/Kernel.php @@ -0,0 +1,38 @@ +import('../config/{packages}/*.yaml'); + $container->import('../config/{packages}/'.$this->environment.'/*.yaml'); + + if (is_file(\dirname(__DIR__).'/config/services.yaml')) { + $container->import('../config/services.yaml'); + $container->import('../config/{services}_'.$this->environment.'.yaml'); + } elseif (is_file($path = \dirname(__DIR__).'/config/services.php')) { + (require $path)($container->withPath($path), $this); + } + } + + protected function configureRoutes(RoutingConfigurator $routes): void + { + $routes->import('../config/{routes}/'.$this->environment.'/*.yaml'); + $routes->import('../config/{routes}/*.yaml'); + + if (is_file(\dirname(__DIR__).'/config/routes.yaml')) { + $routes->import('../config/routes.yaml'); + } elseif (is_file($path = \dirname(__DIR__).'/config/routes.php')) { + (require $path)($routes->withPath($path), $this); + } + } +} diff --git a/symfony.lock b/symfony.lock new file mode 100644 index 0000000..404be5e --- /dev/null +++ b/symfony.lock @@ -0,0 +1,147 @@ +{ + "php": { + "version": "7.3" + }, + "psr/cache": { + "version": "1.0.1" + }, + "psr/container": { + "version": "1.0.0" + }, + "psr/event-dispatcher": { + "version": "1.0.0" + }, + "psr/log": { + "version": "1.1.3" + }, + "symfony/cache": { + "version": "v5.2.0-rc1" + }, + "symfony/cache-contracts": { + "version": "v2.2.0" + }, + "symfony/config": { + "version": "v5.2.0-rc1" + }, + "symfony/console": { + "version": "5.1", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.1", + "ref": "c6d02bdfba9da13c22157520e32a602dbee8a75c" + }, + "files": [ + "bin/console" + ] + }, + "symfony/dependency-injection": { + "version": "v5.2.0-rc1" + }, + "symfony/deprecation-contracts": { + "version": "v2.2.0" + }, + "symfony/dotenv": { + "version": "v5.2.0-rc1" + }, + "symfony/error-handler": { + "version": "v5.2.0-rc1" + }, + "symfony/event-dispatcher": { + "version": "v5.2.0-rc1" + }, + "symfony/event-dispatcher-contracts": { + "version": "v2.2.0" + }, + "symfony/filesystem": { + "version": "v5.2.0-rc1" + }, + "symfony/finder": { + "version": "v5.2.0-rc1" + }, + "symfony/flex": { + "version": "1.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "1.0", + "ref": "c0eeb50665f0f77226616b6038a9b06c03752d8e" + }, + "files": [ + ".env" + ] + }, + "symfony/framework-bundle": { + "version": "5.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.2", + "ref": "6ec87563dcc85cd0c48856dcfbfc29610506d250" + }, + "files": [ + "config/packages/cache.yaml", + "config/packages/framework.yaml", + "config/packages/test/framework.yaml", + "config/preload.php", + "config/routes/dev/framework.yaml", + "config/services.yaml", + "public/index.php", + "src/Controller/.gitignore", + "src/Kernel.php" + ] + }, + "symfony/http-client-contracts": { + "version": "v2.3.1" + }, + "symfony/http-foundation": { + "version": "v5.2.0-rc1" + }, + "symfony/http-kernel": { + "version": "v5.2.0-rc1" + }, + "symfony/polyfill-intl-grapheme": { + "version": "v1.20.0" + }, + "symfony/polyfill-intl-normalizer": { + "version": "v1.20.0" + }, + "symfony/polyfill-mbstring": { + "version": "v1.20.0" + }, + "symfony/polyfill-php73": { + "version": "v1.20.0" + }, + "symfony/polyfill-php80": { + "version": "v1.20.0" + }, + "symfony/routing": { + "version": "5.1", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.1", + "ref": "b4f3e7c95e38b606eef467e8a42a8408fc460c43" + }, + "files": [ + "config/packages/prod/routing.yaml", + "config/packages/routing.yaml", + "config/routes.yaml" + ] + }, + "symfony/service-contracts": { + "version": "v2.2.0" + }, + "symfony/string": { + "version": "v5.2.0-rc1" + }, + "symfony/var-dumper": { + "version": "v5.2.0-rc1" + }, + "symfony/var-exporter": { + "version": "v5.2.0-rc1" + }, + "symfony/yaml": { + "version": "v5.2.0-rc1" + } +}