mirror of
https://github.com/symfony/recipes.git
synced 2026-09-15 09:06:24 +03:00
added version directories
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||
parameters:
|
||||
|
||||
services:
|
||||
@@ -0,0 +1,29 @@
|
||||
services:
|
||||
_defaults:
|
||||
autowire: by_id
|
||||
public: false
|
||||
|
||||
_instanceof:
|
||||
Symfony\Component\Console\Command\Command:
|
||||
tags: ['console.command']
|
||||
public: true
|
||||
|
||||
Twig_ExtensionInterface:
|
||||
tags: ['twig.extension']
|
||||
|
||||
Symfony\Component\EventDispatcher\EventSubscriberInterface:
|
||||
tags: ['kernel.event_subscriber']
|
||||
|
||||
Symfony\Component\Form\FormTypeInterface:
|
||||
tags: ['form.type']
|
||||
|
||||
Symfony\Component\Security\Core\Authorization\VoterInterface:
|
||||
tags: ['security.voter']
|
||||
|
||||
App\:
|
||||
resource: '../../src/{Command,Form,EventSubscriber,Twig,Voter}'
|
||||
|
||||
App\Controller\:
|
||||
resource: '../../src/Controller'
|
||||
public: true
|
||||
tags: ['controller.service_arguments']
|
||||
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
@@ -0,0 +1,18 @@
|
||||
framework:
|
||||
secret: "%env(APP_SECRET)%"
|
||||
#default_locale: en
|
||||
#csrf_protection: null
|
||||
#http_method_override: true
|
||||
#trusted_hosts: null
|
||||
#trusted_proxies: null
|
||||
# https://symfony.com/doc/current/reference/configuration/framework.html#handler-id
|
||||
#session:
|
||||
# handler_id: session.handler.native_file
|
||||
# save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
|
||||
#],
|
||||
#esi: ~
|
||||
#fragments: ~
|
||||
php_errors:
|
||||
log: true
|
||||
router:
|
||||
strict_requirements: null
|
||||
@@ -0,0 +1,4 @@
|
||||
framework:
|
||||
test: null
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
||||
@@ -0,0 +1,8 @@
|
||||
#index:
|
||||
# path: /
|
||||
# defaults: { _controller: "App\\Controller\\SomeController::index" }
|
||||
|
||||
# if annotations are enabled
|
||||
#controllers:
|
||||
# resource: ../src/Controller/
|
||||
# type: annotation
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"bundles": {
|
||||
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle": ["all"]
|
||||
},
|
||||
"copy-from-recipe": {
|
||||
"etc/": "%ETC_DIR%/",
|
||||
"src/": "%SRC_DIR%/",
|
||||
"web/": "%WEB_DIR%/"
|
||||
},
|
||||
"composer-scripts": {
|
||||
"make cache-warmup": "script",
|
||||
"assets:install --symlink --relative %WEB_DIR%": "symfony-cmd"
|
||||
},
|
||||
"env": {
|
||||
"APP_ENV": "dev",
|
||||
"APP_DEBUG": "1",
|
||||
"APP_SECRET": "%generate(secret)%"
|
||||
},
|
||||
"makefile": [
|
||||
"cache-clear:",
|
||||
"\t@test -f bin/console && bin/console cache:clear --no-warmup || rm -rf var/cache/*",
|
||||
".PHONY: cache-clear",
|
||||
"cache-warmup: cache-clear",
|
||||
"\t@test -f bin/console && bin/console cache:warmup || echo \"cannot warmup the cache (needs symfony/console)\"",
|
||||
".PHONY: cache-warmup",
|
||||
"serve:",
|
||||
"\t@echo \"\\033[32;49mServer listening on http://127.0.0.1:8000\\033[39m\"",
|
||||
"\t@echo \"Quit the server with CTRL-C.\"",
|
||||
"\t@echo \"Run \\033[32mcomposer require symfony/web-server-bundle\\033[39m for a better web server\"",
|
||||
"\tphp -S 127.0.0.1:8000 -t web",
|
||||
".PHONY: serve"
|
||||
],
|
||||
"gitignore": [
|
||||
".env",
|
||||
"/var/",
|
||||
"/vendor/",
|
||||
"/web/bundles/"
|
||||
],
|
||||
"post-install-output": [
|
||||
"<bg=blue;fg=white> </>",
|
||||
"<bg=blue;fg=white> What's next? </>",
|
||||
"<bg=blue;fg=white> </>",
|
||||
"",
|
||||
" * <fg=blue>Run</> your application:",
|
||||
" 1. Execute the <comment>make serve</comment> command;",
|
||||
" 2. Browse to the <comment>http://localhost:8000/</comment> URL.",
|
||||
"",
|
||||
" * <fg=blue>Read</> the documentation at <comment>https://symfony.com/doc</comment>"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
|
||||
|
||||
public function getCacheDir()
|
||||
{
|
||||
return dirname(__DIR__).'/var/cache/'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
{
|
||||
return dirname(__DIR__).'/var/logs';
|
||||
}
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
$contents = require dirname($this->getRootDir()).'/etc/bundles.php';
|
||||
foreach ($contents as $class => $envs) {
|
||||
if (isset($envs['all']) || isset($envs[$this->getEnvironment()])) {
|
||||
yield new $class();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
|
||||
{
|
||||
$confDir = dirname($this->getRootDir()).'/etc';
|
||||
$loader->import($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob');
|
||||
if (is_dir($confDir.'/packages/'.$this->getEnvironment())) {
|
||||
$loader->import($confDir.'/packages/'.$this->getEnvironment().'/**/*'.self::CONFIG_EXTS, 'glob');
|
||||
}
|
||||
$loader->import($confDir.'/container'.self::CONFIG_EXTS, 'glob');
|
||||
}
|
||||
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||
{
|
||||
$confDir = dirname($this->getRootDir()).'/etc';
|
||||
if (is_dir($confDir.'/routing/')) {
|
||||
$routes->import($confDir.'/routing/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||
}
|
||||
if (is_dir($confDir.'/routing/'.$this->getEnvironment())) {
|
||||
$routes->import($confDir.'/routing/'.$this->getEnvironment().'/**/*'.self::CONFIG_EXTS, '/', 'glob');
|
||||
}
|
||||
$routes->import($confDir.'/routing'.self::CONFIG_EXTS, '/', 'glob');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
// The check is to ensure we don't use .env in production
|
||||
if (!getenv('APP_ENV')) {
|
||||
(new Dotenv())->load(__DIR__.'/../.env');
|
||||
}
|
||||
|
||||
if (getenv('APP_DEBUG')) {
|
||||
// WARNING: You should setup permissions the proper way!
|
||||
// REMOVE the following PHP line and read
|
||||
// https://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
|
||||
umask(0000);
|
||||
|
||||
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
||||
// Feel free to remove this, extend it, or make something more sophisticated.
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
}
|
||||
|
||||
Debug::enable();
|
||||
}
|
||||
|
||||
// Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED);
|
||||
|
||||
$kernel = new Kernel(getenv('APP_ENV'), getenv('APP_DEBUG'));
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
$kernel->terminate($request, $response);
|
||||
Reference in New Issue
Block a user