Skip to content

Commit

Permalink
Change directory structure and autoload process
Browse files Browse the repository at this point in the history
  • Loading branch information
uzurstuv authored and giorgio654 committed Mar 12, 2019
1 parent dbb023a commit 46a268a
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ app/logs
!app/logs/.gitkeep
!app/build/logs/.gitkeep

var/

bin/chromedriver
bin/chromedriver.exe
bin/selenium-server.jar
Expand Down
30 changes: 29 additions & 1 deletion app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,47 @@ public function registerBundles()
);

if (in_array($this->getEnvironment(), array('dev', 'test', 'staging'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Hpatoio\DeployBundle\DeployBundle();

if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
}


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';
}

/** @inheritdoc */
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(
function (ContainerBuilder $container) {
$container->setParameter('container.autowiring.strict_mode', true);
$container->setParameter('container.dumper.inline_class_loader', true);
$container->addObjectResource($this);
}
);
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');

}

protected function getContainerBuilder()
Expand Down
16 changes: 0 additions & 16 deletions app/autoload.php

This file was deleted.

20 changes: 0 additions & 20 deletions app/bootstrap.test.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ framework:
translator: { fallbacks: ["%cocorico.locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
Expand Down
18 changes: 6 additions & 12 deletions app/console → bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@ use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);

set_time_limit(0);


//Set timezone to UTC
date_default_timezone_set('UTC');

/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__ . '/autoload.php';

require __DIR__ . '/../vendor/autoload.php';
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';

$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
if ($debug) {
Debug::enable();
}

$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);

3 changes: 2 additions & 1 deletion app/check.php → bin/symfony_requirements
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env php
<?php

require_once dirname(__FILE__).'/SymfonyRequirements.php';
require_once dirname(__FILE__) . '/../var/SymfonyRequirements.php';

$lineSize = 70;
$symfonyRequirements = new SymfonyRequirements();
Expand Down
34 changes: 19 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
"app/AppCache.php"
]
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Cocolabs-SAS/SonataUserBundle"
}
],
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
"require": {
"php": "^7.1",
"alcaeus/mongo-php-adapter": "^1.1",
Expand Down Expand Up @@ -100,30 +102,32 @@
"wikimedia/composer-merge-plugin": "^1.4"
},
"scripts": {
"post-install-cmd": [
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
"@symfony-scripts"
]
},
"config": {
"bin-dir": "bin",
"component-dir": "web/assets"
"component-dir": "web/assets",
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
Expand All @@ -141,4 +145,4 @@
"provide": {
"ext-mongo": "1.6.14"
}
}
}
15 changes: 1 addition & 14 deletions web/app.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;

/**
* @var Composer\Autoload\ClassLoader
*/
$loader = require __DIR__ . '/../app/autoload.php';
include_once __DIR__ . '/../app/bootstrap.php.cache';

// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.

$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);

$loader = require __DIR__ . '/../vendor/autoload.php';

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
Expand Down
8 changes: 3 additions & 5 deletions web/app_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
use Symfony\Component\HttpFoundation\Request;

// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//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'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
) {
// header('HTTP/1.0 403 Forbidden');
// exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
Expand All @@ -21,11 +20,10 @@
/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__ . '/../app/autoload.php';
$loader = require __DIR__ . '/../vendor/autoload.php';
Debug::enable();

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
3 changes: 1 addition & 2 deletions web/app_staging.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__ . '/../app/autoload.php';
$loader = require __DIR__ . '/../vendor/autoload.php';
Debug::enable();

$kernel = new AppKernel('staging', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
3 changes: 1 addition & 2 deletions web/app_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__ . '/../app/autoload.php';
$loader = require __DIR__ . '/../vendor/autoload.php';
Debug::enable();

$kernel = new AppKernel('test', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
2 changes: 1 addition & 1 deletion web/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
exit('This script is only accessible from localhost.');
}

require_once dirname(__FILE__).'/../app/SymfonyRequirements.php';
require_once dirname(__FILE__) . '/../var/SymfonyRequirements.php';

$symfonyRequirements = new SymfonyRequirements();

Expand Down

0 comments on commit 46a268a

Please sign in to comment.