Skip to content

Commit

Permalink
Merge pull request #6822 from pamil/symfony3-directorystructure
Browse files Browse the repository at this point in the history
Use Symfony 3 directory structure
  • Loading branch information
pjedrzejewski committed Nov 23, 2016
2 parents 9ab5029 + 51f1fec commit e9a7f64
Show file tree
Hide file tree
Showing 34 changed files with 249 additions and 120 deletions.
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
/.php_cs.cache

/app/*.cache
/app/cache
/app/logs

/app/check.php
/app/SymfonyRequirements.php

/app/config/parameters.yml
/app/config/*.local.yml
/var/*
!/var/.gitkeep

/web/assets
/web/bundles
/web/css
/web/js
/web/media

/bin
/vendor
/node_modules

Expand Down
1 change: 0 additions & 1 deletion app/.htaccess

This file was deleted.

4 changes: 2 additions & 2 deletions app/TestAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public function shutdown()
return;
}

if (!in_array($this->environment, ['test', 'test_cached'], true)) {
if (!in_array($this->getEnvironment(), ['test', 'test_cached'], true)) {
parent::shutdown();

return;
}

$container = $this->container;
$container = $this->getContainer();
parent::shutdown();
$this->cleanupContainer($container);
}
Expand Down
18 changes: 3 additions & 15 deletions app/autoload.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;

/** @var ClassLoader $loader */
$loader = require __DIR__.'/../vendor/autoload.php';

// Intl stubs.
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
}

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
AnnotationRegistry::registerLoader([$loader, 'loadClass']);

return $loader;
26 changes: 0 additions & 26 deletions app/console

This file was deleted.

28 changes: 28 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php

use Symfony\Bundle\FrameworkBundle\Console\Application;
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/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);

set_time_limit(0);

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

$input = new ArgvInput();
$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);
143 changes: 143 additions & 0 deletions bin/symfony_requirements
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/usr/bin/env php
<?php

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

$lineSize = 70;
$symfonyRequirements = new SymfonyRequirements();
$iniPath = $symfonyRequirements->getPhpIniConfigPath();

echo_title('Symfony Requirements Checker');

echo '> PHP is using the following php.ini file:'.PHP_EOL;
if ($iniPath) {
echo_style('green', ' '.$iniPath);
} else {
echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!');
}

echo PHP_EOL.PHP_EOL;

echo '> Checking Symfony requirements:'.PHP_EOL.' ';

$messages = array();
foreach ($symfonyRequirements->getRequirements() as $req) {
/** @var $req Requirement */
if ($helpText = get_error_message($req, $lineSize)) {
echo_style('red', 'E');
$messages['error'][] = $helpText;
} else {
echo_style('green', '.');
}
}

$checkPassed = empty($messages['error']);

foreach ($symfonyRequirements->getRecommendations() as $req) {
if ($helpText = get_error_message($req, $lineSize)) {
echo_style('yellow', 'W');
$messages['warning'][] = $helpText;
} else {
echo_style('green', '.');
}
}

if ($checkPassed) {
echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
} else {
echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');

echo_title('Fix the following mandatory requirements', 'red');

foreach ($messages['error'] as $helpText) {
echo ' * '.$helpText.PHP_EOL;
}
}

if (!empty($messages['warning'])) {
echo_title('Optional recommendations to improve your setup', 'yellow');

foreach ($messages['warning'] as $helpText) {
echo ' * '.$helpText.PHP_EOL;
}
}

echo PHP_EOL;
echo_style('title', 'Note');
echo ' The command console could use a different php.ini file'.PHP_EOL;
echo_style('title', '~~~~');
echo ' than the one used with your web server. To be on the'.PHP_EOL;
echo ' safe side, please check the requirements from your web'.PHP_EOL;
echo ' server using the ';
echo_style('yellow', 'web/config.php');
echo ' script.'.PHP_EOL;
echo PHP_EOL;

exit($checkPassed ? 0 : 1);

function get_error_message(Requirement $requirement, $lineSize)
{
if ($requirement->isFulfilled()) {
return;
}

$errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
$errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL;

return $errorMessage;
}

function echo_title($title, $style = null)
{
$style = $style ?: 'title';

echo PHP_EOL;
echo_style($style, $title.PHP_EOL);
echo_style($style, str_repeat('~', strlen($title)).PHP_EOL);
echo PHP_EOL;
}

function echo_style($style, $message)
{
// ANSI color codes
$styles = array(
'reset' => "\033[0m",
'red' => "\033[31m",
'green' => "\033[32m",
'yellow' => "\033[33m",
'error' => "\033[37;41m",
'success' => "\033[37;42m",
'title' => "\033[34m",
);
$supports = has_color_support();

echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
}

function echo_block($style, $title, $message)
{
$message = ' '.trim($message).' ';
$width = strlen($message);

echo PHP_EOL.PHP_EOL;

echo_style($style, str_repeat(' ', $width).PHP_EOL);
echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_repeat(' ', $width).PHP_EOL);
}

function has_color_support()
{
static $support;

if (null === $support) {
if (DIRECTORY_SEPARATOR == '\\') {
$support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
} else {
$support = function_exists('posix_isatty') && @posix_isatty(STDOUT);
}
}

return $support;
}
26 changes: 15 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,39 +151,43 @@
"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::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"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::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"autoload": {
"psr-4": {
"Sylius\\Behat\\": "src/Sylius/Behat/",
"Sylius\\Bundle\\": "src/Sylius/Bundle/",
"Sylius\\Component\\": "src/Sylius/Component/"
}
},
"classmap": ["app/AppKernel.php", "app/AppCache.php"]
},
"autoload-dev": {
"psr-4": {
"Sylius\\Tests\\": "tests/"
}
},
"config": {
"bin-dir": "bin"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"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"
},
"symfony-app-dir": "app",
"symfony-web-dir": "web"
"branch-alias": {
"dev-master": "1.0-dev"
}
}
}
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions etc/travis/suites/application/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bash/common.lib.sh"

print_header "Setting the application up" "Sylius"
run_command "app/console doctrine:database:create --env=test_cached -vvv" || exit $? # Have to be run with debug = true, to omit generating proxies before setting up the database
run_command "app/console cache:warmup --env=test_cached --no-debug -vvv" || exit $?
run_command "app/console doctrine:migrations:migrate --no-interaction --env=test_cached --no-debug -vvv" || exit $?
run_command "bin/console doctrine:database:create --env=test_cached -vvv" || exit $? # Have to be run with debug = true, to omit generating proxies before setting up the database
run_command "bin/console cache:warmup --env=test_cached --no-debug -vvv" || exit $?
run_command "bin/console doctrine:migrations:migrate --no-interaction --env=test_cached --no-debug -vvv" || exit $?

print_header "Setting the web assets up" "sylius"
run_command "app/console assets:install --env=test_cached --no-debug -vvv" || exit $?
run_command "bin/console assets:install --env=test_cached --no-debug -vvv" || exit $?
run_command "npm run gulp" || exit $?
4 changes: 2 additions & 2 deletions etc/travis/suites/application/script/test-behat-with-cli
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ run_behat() {
local code=0

print_header "Testing (Behat - CLI commands, regular scenarios; @cli && ~@todo)" "Sylius"
run_command "bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@cli && ~@todo\"" || code=$?
run_command "vendor/bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@cli && ~@todo\"" || code=$?
if [[ ${code} = 1 ]]; then
run_command "bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@cli && ~@todo\" --rerun" ; code=$?
run_command "vendor/bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@cli && ~@todo\" --rerun" ; code=$?
fi

return ${code}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ prepare_for_behat_with_js() {
fi

# Run Selenium with ChromeDriver
run_command "bin/selenium-server-standalone -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver > $SYLIUS_BUILD_DIR/selenium.log 2>&1 &"
run_command "vendor/bin/selenium-server-standalone -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver > $SYLIUS_BUILD_DIR/selenium.log 2>&1 &"

# Run webserver
run_command "app/console server:run 127.0.0.1:8080 --env=test_cached --router=app/config/router_test_cached.php --no-debug > $SYLIUS_BUILD_DIR/webserver.log 2>&1 &"
run_command "bin/console server:run 127.0.0.1:8080 --env=test_cached --router=app/config/router_test_cached.php --no-debug > $SYLIUS_BUILD_DIR/webserver.log 2>&1 &"
}

run_behat() {
local code=0

print_header "Testing (Behat - brand new, javascript scenarios; @javascript && ~@todo && ~@cli)" "Sylius"
run_command "bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@javascript && ~@todo && ~@cli\"" || code=$?
run_command "vendor/bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@javascript && ~@todo && ~@cli\"" || code=$?
if [[ ${code} = 1 ]]; then
run_command "bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@javascript && ~@todo && ~@cli\" --rerun" ; code=$?
run_command "vendor/bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"@javascript && ~@todo && ~@cli\" --rerun" ; code=$?
fi

return ${code}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ run_behat() {
local code=0

print_header "Testing (Behat - brand new, regular scenarios; ~@javascript && ~@todo && ~@cli)" "Sylius"
run_command "bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"~@javascript && ~@todo && ~@cli\"" || code=$?
run_command "vendor/bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"~@javascript && ~@todo && ~@cli\"" || code=$?
if [[ ${code} = 1 ]]; then
run_command "bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"~@javascript && ~@todo && ~@cli\" --rerun" ; code=$?
run_command "vendor/bin/behat --strict --no-interaction -vvv -f progress -p cached --tags=\"~@javascript && ~@todo && ~@cli\" --rerun" ; code=$?
fi

return ${code}
Expand Down
Loading

0 comments on commit e9a7f64

Please sign in to comment.