Switch to Symfony 3 structure

This commit is contained in:
Jeremy Benoist 2016-01-14 18:15:07 +01:00
parent 1d405d0e62
commit 73cd160bfc
21 changed files with 65 additions and 33 deletions

23
.gitignore vendored
View file

@ -1,25 +1,20 @@
# Cache and logs (Symfony2) # Cache, logs & sessions
/app/cache/* /var/*
/app/logs/* !/var/cache
!app/cache/.gitkeep
!app/logs/.gitkeep
# Cache and logs (Symfony3)
/var/cache/* /var/cache/*
/var/logs/*
!var/cache/.gitkeep !var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep !var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php
# Parameters # Parameters
/app/config/parameters.yml /app/config/parameters.yml
/app/config/parameters.ini
# Managed by Composer # Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/ /vendor/
# Assets and user uploads # Assets and user uploads

View file

@ -7,7 +7,7 @@ class AppKernel extends Kernel
{ {
public function registerBundles() public function registerBundles()
{ {
$bundles = array( $bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(),
@ -33,9 +33,9 @@ class AppKernel extends Kernel
new KPhoen\RulerZBundle\KPhoenRulerZBundle(), new KPhoen\RulerZBundle\KPhoenRulerZBundle(),
new Wallabag\ImportBundle\WallabagImportBundle(), new Wallabag\ImportBundle\WallabagImportBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
); ];
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) { if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
@ -46,6 +46,21 @@ class AppKernel extends Kernel
return $bundles; return $bundles;
} }
public function getRootDir()
{
return __DIR__;
}
public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}
public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}
public function registerContainerConfiguration(LoaderInterface $loader) public function registerContainerConfiguration(LoaderInterface $loader)
{ {
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');

View file

@ -8,6 +8,6 @@ use Composer\Autoload\ClassLoader;
*/ */
$loader = require __DIR__.'/../vendor/autoload.php'; $loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass')); AnnotationRegistry::registerLoader([$loader, 'loadClass']);
return $loader; return $loader;

View file

@ -21,7 +21,8 @@ framework:
trusted_proxies: ~ trusted_proxies: ~
session: session:
# handler_id set to null will use default session handler from php.ini # handler_id set to null will use default session handler from php.ini
handler_id: ~ handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~ fragments: ~
http_method_override: true http_method_override: true

View file

@ -17,13 +17,14 @@ monolog:
type: stream type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log" path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug level: debug
channels: [!event]
console: console:
type: console type: console
bubble: false bubble: false
verbosity_levels: verbosity_levels:
VERBOSITY_VERBOSE: INFO VERBOSITY_VERBOSE: INFO
VERBOSITY_VERY_VERBOSE: DEBUG VERBOSITY_VERY_VERBOSE: DEBUG
channels: ["!doctrine"] channels: [!event, !doctrine]
console_very_verbose: console_very_verbose:
type: console type: console
bubble: false bubble: false
@ -31,7 +32,7 @@ monolog:
VERBOSITY_VERBOSE: NOTICE VERBOSITY_VERBOSE: NOTICE
VERBOSITY_VERY_VERBOSE: NOTICE VERBOSITY_VERY_VERBOSE: NOTICE
VERBOSITY_DEBUG: DEBUG VERBOSITY_DEBUG: DEBUG
channels: ["doctrine"] channels: [doctrine]
assetic: assetic:
use_controller: true use_controller: true

6
app/console → bin/console Executable file → Normal file
View file

@ -14,11 +14,11 @@ set_time_limit(0);
/** /**
* @var Composer\Autoload\ClassLoader $loader * @var Composer\Autoload\ClassLoader $loader
*/ */
$loader = require __DIR__.'/autoload.php'; $loader = require __DIR__.'/../app/autoload.php';
$input = new ArgvInput(); $input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
if ($debug) { if ($debug) {
Debug::enable(); Debug::enable();

1
bin/doctrine Symbolic link
View file

@ -0,0 +1 @@
../vendor/doctrine/orm/bin/doctrine

1
bin/doctrine-dbal Symbolic link
View file

@ -0,0 +1 @@
../vendor/doctrine/dbal/bin/doctrine-dbal

1
bin/doctrine-migrations Symbolic link
View file

@ -0,0 +1 @@
../vendor/doctrine/migrations/bin/doctrine-migrations

1
bin/doctrine.php Symbolic link
View file

@ -0,0 +1 @@
../vendor/doctrine/orm/bin/doctrine.php

Binary file not shown.

1
bin/security-checker Symbolic link
View file

@ -0,0 +1 @@
../vendor/sensiolabs/security-checker/security-checker

View file

@ -1,6 +1,7 @@
#!/usr/bin/env php
<?php <?php
require_once dirname(__FILE__).'/SymfonyRequirements.php'; require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
$lineSize = 70; $lineSize = 70;
$symfonyRequirements = new SymfonyRequirements(); $symfonyRequirements = new SymfonyRequirements();

0
var/logs/.gitkeep Normal file
View file

0
var/sessions/.gitkeep Normal file
View file

View file

@ -5,6 +5,18 @@
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php DirectoryIndex app.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks
# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
# to the front controller "/app.php" but be rewritten to "/app.php/app".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine On RewriteEngine On
@ -18,9 +30,9 @@ DirectoryIndex app.php
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1] RewriteRule ^(.*) - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by apache # Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} . RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect to URI without front controller to prevent duplicate content # Redirect to URI without front controller to prevent duplicate content
# (with and without `/app.php`). Only do this redirect on the initial # (with and without `/app.php`). Only do this redirect on the initial
@ -34,15 +46,15 @@ DirectoryIndex app.php
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution) # following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
# If the requested filename exists, simply serve it. # If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories. # We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L] RewriteRule ^ - [L]
# Rewrite all other queries to the front controller. # Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/app.php [L] RewriteRule ^ %{ENV:BASE}/app.php [L]
</IfModule> </IfModule>
<IfModule !mod_rewrite.c> <IfModule !mod_rewrite.c>

View file

@ -6,7 +6,7 @@ use Symfony\Component\HttpFoundation\Request;
* @var Composer\Autoload\ClassLoader * @var Composer\Autoload\ClassLoader
*/ */
$loader = require __DIR__.'/../app/autoload.php'; $loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache'; include_once __DIR__.'/../var/bootstrap.php.cache';
// Enable APC for autoloading to improve performance. // Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix // You should change the ApcClassLoader first argument to a unique prefix

View file

@ -12,7 +12,7 @@ use Symfony\Component\Debug\Debug;
// Feel free to remove this, extend it, or make something more sophisticated. // Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server') || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
) { ) {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');

View file

@ -1,2 +1,4 @@
# www.robotstxt.org/
# www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449
User-agent: * User-agent: *
Disallow: /