Skip to content

Commit 781b1c1

Browse files
committed
Added FrameworkBundle 5.1 recipe
1 parent 3ba04b9 commit 781b1c1

File tree

12 files changed

+212
-0
lines changed

12 files changed

+212
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Symfony\Component\Dotenv\Dotenv;
4+
5+
require dirname(__DIR__).'/vendor/autoload.php';
6+
7+
// Load cached env vars if the .env.local.php file exists
8+
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
9+
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) {
10+
foreach ($env as $k => $v) {
11+
$_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
12+
}
13+
} elseif (!class_exists(Dotenv::class)) {
14+
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
15+
} else {
16+
// load all the .env files
17+
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
18+
}
19+
20+
$_SERVER += $_ENV;
21+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
22+
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
23+
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
framework:
2+
cache:
3+
# Unique name of your app: used to compute stable namespaces for cache keys.
4+
#prefix_seed: your_vendor_name/app_name
5+
6+
# The "app" cache stores to the filesystem by default.
7+
# The data in this cache should persist between deploys.
8+
# Other options include:
9+
10+
# Redis
11+
#app: cache.adapter.redis
12+
#default_redis_provider: redis://localhost
13+
14+
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
15+
#app: cache.adapter.apcu
16+
17+
# Namespaced pools use the above "app" backend by default
18+
#pools:
19+
#my.dedicated.cache: null
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
framework:
2+
secret: '%env(APP_SECRET)%'
3+
#csrf_protection: true
4+
#http_method_override: true
5+
6+
# Enables session support. Note that the session will ONLY be started if you read or write from it.
7+
# Remove or comment this section to explicitly disable session support.
8+
session:
9+
handler_id: null
10+
cookie_secure: auto
11+
cookie_samesite: lax
12+
13+
#esi: true
14+
#fragments: true
15+
php_errors:
16+
log: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework:
2+
test: true
3+
session:
4+
storage_id: session.storage.mock_file
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_errors:
2+
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
3+
prefix: /_error
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/prod.decrypt.private.php
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file is the entry point to configure your own services.
2+
# Files in the packages/ subdirectory configure your dependencies.
3+
4+
# Put parameters here that don't need to change on each machine where the app is deployed
5+
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
6+
parameters:
7+
8+
services:
9+
# default configuration for services in *this* file
10+
_defaults:
11+
autowire: true # Automatically injects dependencies in your services.
12+
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
13+
14+
# makes classes in src/ available to be used as services
15+
# this creates a service per class whose id is the fully-qualified class name
16+
App\:
17+
resource: '../src/*'
18+
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
19+
20+
# controllers are imported separately to make sure services can be injected
21+
# as action arguments even if you don't extend any base controller class
22+
App\Controller\:
23+
resource: '../src/Controller'
24+
tags: ['controller.service_arguments']
25+
26+
# add more service definitions when explicit configuration is needed
27+
# please note that last definitions always *replace* previous ones
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"bundles": {
3+
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle": ["all"]
4+
},
5+
"copy-from-recipe": {
6+
"config/": "%CONFIG_DIR%/",
7+
"public/": "%PUBLIC_DIR%/",
8+
"src/": "%SRC_DIR%/"
9+
},
10+
"composer-scripts": {
11+
"cache:clear": "symfony-cmd",
12+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
13+
},
14+
"env": {
15+
"APP_ENV": "dev",
16+
"APP_SECRET": "%generate(secret)%",
17+
"#TRUSTED_PROXIES": "127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16",
18+
"#TRUSTED_HOSTS": "'^localhost|example\\.com$'"
19+
},
20+
"gitignore": [
21+
"/.env.local",
22+
"/.env.local.php",
23+
"/.env.*.local",
24+
"/%PUBLIC_DIR%/bundles/",
25+
"/%VAR_DIR%/",
26+
"/vendor/"
27+
]
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<bg=blue;fg=white> </>
2+
<bg=blue;fg=white> What's next? </>
3+
<bg=blue;fg=white> </>
4+
5+
* <fg=blue>Run</> your application:
6+
1. Go to the project directory
7+
2. Create your code repository with the <comment>git init</comment> command
8+
3. Download the Symfony CLI at <comment>https://symfony.com/download</> to install a development web server
9+
10+
* <fg=blue>Read</> the documentation at <comment>https://symfony.com/doc</>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use App\Kernel;
4+
use Symfony\Component\ErrorHandler\Debug;
5+
use Symfony\Component\HttpFoundation\Request;
6+
7+
require dirname(__DIR__).'/config/bootstrap.php';
8+
9+
if ($_SERVER['APP_DEBUG']) {
10+
umask(0000);
11+
12+
Debug::enable();
13+
}
14+
15+
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
16+
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
17+
}
18+
19+
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
20+
Request::setTrustedHosts([$trustedHosts]);
21+
}
22+
23+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
24+
$request = Request::createFromGlobals();
25+
$response = $kernel->handle($request);
26+
$response->send();
27+
$kernel->terminate($request, $response);

0 commit comments

Comments
 (0)