Skip to content

Commit 2278daf

Browse files
authored
Merge pull request #341 from symfony-cmf/sf3-directory-structure
Use the Symfony 3 directory structure
2 parents 90ffc97 + c3a3006 commit 2278daf

24 files changed

+1026
-93
lines changed

.gitignore

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
composer.phar
2-
app/cache/*
3-
app/logs/*
4-
app/config/parameters.yml
5-
app/config/phpcr.yml
6-
app/bootstrap.php.cache
7-
app/app.sqlite
8-
app/check.php
9-
app/SymfonyRequirements.php
10-
web/bundles/
11-
web/js/
12-
web/css/
13-
web/media
14-
web/assetic
15-
build/
1+
/app/config/parameters.yml
2+
/build/
3+
/phpunit.xml
4+
/var/*
5+
!/var/cache
6+
/var/cache/*
7+
!var/cache/.gitkeep
8+
!/var/logs
9+
/var/logs/*
10+
!var/logs/.gitkeep
11+
!/var/sessions
12+
/var/sessions/*
13+
!var/sessions/.gitkeep
14+
!var/SymfonyRequirements.php
1615
/vendor/
17-
jackrabbit/
18-
jackrabbit-standalone-*.jar
19-
vagrant/.vagrant
20-
bin/
16+
/web/bundles/
17+
18+
/app/config/phpcr.yml
19+
/app/app.sqlite
20+
/jackrabbit/
21+
/jackrabbit-standalone-*.jar
22+
/vagrant/.vagrant

.platform.app.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
name: php
66

77
# The toolstack used to build the application.
8-
type: php:5.6
8+
type: php:7.0
99
build:
1010
flavor: symfony
1111

@@ -47,24 +47,24 @@ disk: 2048
4747

4848
# The mounts that will be performed when the package is deployed.
4949
mounts:
50-
"/app/cache": "shared:files/cache"
51-
"/app/logs": "shared:files/logs"
50+
"/var/cache": "shared:files/cache"
51+
"/var/logs": "shared:files/logs"
5252

5353
# The hooks that will be performed when the package is deployed.
5454
hooks:
5555
build: |
5656
rm web/app_dev.php
5757
# place sqlite file into /tmp so that we can write to it during deploy
5858
sed -i 's@%kernel.root_dir%/app.sqlite@/tmp/app.sqlite@' app/config/parameters.yml
59-
app/console --env=prod assets:install -n --no-debug
60-
app/console --env=prod assetic:dump -n --no-debug
59+
bin/console --env=prod assets:install -n --no-debug
60+
bin/console --env=prod assetic:dump -n --no-debug
6161
deploy: |
6262
# force clearing the cache
63-
rm -rf app/cache
64-
app/console doctrine:phpcr:init:dbal --drop --force -n
65-
app/console doctrine:phpcr:repository:init -n
66-
app/console doctrine:phpcr:fixtures:load -n
67-
app/console --env=prod cache:warmup -n --no-debug
63+
rm -rf var/cache
64+
bin/console doctrine:phpcr:init:dbal --drop --force -n
65+
bin/console doctrine:phpcr:repository:init -n
66+
bin/console doctrine:phpcr:fixtures:load -n
67+
bin/console --env=prod cache:warmup -n --no-debug
6868
6969
runtime:
7070
extensions:

.styleci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
preset: symfony
22

33
disabled: [phpdoc_to_comment, phpdoc_var_without_name]
4+
5+
finder:
6+
exclude: [var]

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ install: if [ "$COMPOSER_INSTALL" != "1" ]; then composer update --no-scripts --
3737
before_script:
3838
- cp app/config/phpcr_${TRANSPORT}.yml.dist app/config/phpcr.yml
3939
- composer run-script post-update-cmd
40-
- ./app/tests/travis_${TRANSPORT}.sh
41-
- app/console doctrine:phpcr:workspace:create sandbox_test -e=test
42-
- app/console doctrine:phpcr:repository:init -e=test
40+
- ./tests/travis_${TRANSPORT}.sh
41+
- bin/console doctrine:phpcr:workspace:create sandbox_test -e=test
42+
- bin/console doctrine:phpcr:repository:init -e=test
4343

44-
script: phpunit -c app
44+
script: phpunit
4545

4646
notifications:
4747
irc: "irc.freenode.org#symfony-cmf"

app/AppKernel.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ public function registerBundles()
8484
return $bundles;
8585
}
8686

87+
public function getRootDir()
88+
{
89+
return __DIR__;
90+
}
91+
92+
public function getCacheDir()
93+
{
94+
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
95+
}
96+
97+
public function getLogDir()
98+
{
99+
return dirname(__DIR__).'/var/logs';
100+
}
101+
87102
public function registerContainerConfiguration(LoaderInterface $loader)
88103
{
89104
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');

app/phpunit.xml.dist

Lines changed: 0 additions & 44 deletions
This file was deleted.

app/tests/travis_jackrabbit.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/console renamed to bin/console

File renamed without changes.

bin/symfony_requirements

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
5+
6+
$lineSize = 70;
7+
$symfonyRequirements = new SymfonyRequirements();
8+
$iniPath = $symfonyRequirements->getPhpIniConfigPath();
9+
10+
echo_title('Symfony Requirements Checker');
11+
12+
echo '> PHP is using the following php.ini file:'.PHP_EOL;
13+
if ($iniPath) {
14+
echo_style('green', ' '.$iniPath);
15+
} else {
16+
echo_style('yellow', ' WARNING: No configuration file (php.ini) used by PHP!');
17+
}
18+
19+
echo PHP_EOL.PHP_EOL;
20+
21+
echo '> Checking Symfony requirements:'.PHP_EOL.' ';
22+
23+
$messages = array();
24+
foreach ($symfonyRequirements->getRequirements() as $req) {
25+
/** @var $req Requirement */
26+
if ($helpText = get_error_message($req, $lineSize)) {
27+
echo_style('red', 'E');
28+
$messages['error'][] = $helpText;
29+
} else {
30+
echo_style('green', '.');
31+
}
32+
}
33+
34+
$checkPassed = empty($messages['error']);
35+
36+
foreach ($symfonyRequirements->getRecommendations() as $req) {
37+
if ($helpText = get_error_message($req, $lineSize)) {
38+
echo_style('yellow', 'W');
39+
$messages['warning'][] = $helpText;
40+
} else {
41+
echo_style('green', '.');
42+
}
43+
}
44+
45+
if ($checkPassed) {
46+
echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
47+
} else {
48+
echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');
49+
50+
echo_title('Fix the following mandatory requirements', 'red');
51+
52+
foreach ($messages['error'] as $helpText) {
53+
echo ' * '.$helpText.PHP_EOL;
54+
}
55+
}
56+
57+
if (!empty($messages['warning'])) {
58+
echo_title('Optional recommendations to improve your setup', 'yellow');
59+
60+
foreach ($messages['warning'] as $helpText) {
61+
echo ' * '.$helpText.PHP_EOL;
62+
}
63+
}
64+
65+
echo PHP_EOL;
66+
echo_style('title', 'Note');
67+
echo ' The command console could use a different php.ini file'.PHP_EOL;
68+
echo_style('title', '~~~~');
69+
echo ' than the one used with your web server. To be on the'.PHP_EOL;
70+
echo ' safe side, please check the requirements from your web'.PHP_EOL;
71+
echo ' server using the ';
72+
echo_style('yellow', 'web/config.php');
73+
echo ' script.'.PHP_EOL;
74+
echo PHP_EOL;
75+
76+
exit($checkPassed ? 0 : 1);
77+
78+
function get_error_message(Requirement $requirement, $lineSize)
79+
{
80+
if ($requirement->isFulfilled()) {
81+
return;
82+
}
83+
84+
$errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
85+
$errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL;
86+
87+
return $errorMessage;
88+
}
89+
90+
function echo_title($title, $style = null)
91+
{
92+
$style = $style ?: 'title';
93+
94+
echo PHP_EOL;
95+
echo_style($style, $title.PHP_EOL);
96+
echo_style($style, str_repeat('~', strlen($title)).PHP_EOL);
97+
echo PHP_EOL;
98+
}
99+
100+
function echo_style($style, $message)
101+
{
102+
// ANSI color codes
103+
$styles = array(
104+
'reset' => "\033[0m",
105+
'red' => "\033[31m",
106+
'green' => "\033[32m",
107+
'yellow' => "\033[33m",
108+
'error' => "\033[37;41m",
109+
'success' => "\033[37;42m",
110+
'title' => "\033[34m",
111+
);
112+
$supports = has_color_support();
113+
114+
echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
115+
}
116+
117+
function echo_block($style, $title, $message)
118+
{
119+
$message = ' '.trim($message).' ';
120+
$width = strlen($message);
121+
122+
echo PHP_EOL.PHP_EOL;
123+
124+
echo_style($style, str_repeat(' ', $width).PHP_EOL);
125+
echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL);
126+
echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL);
127+
echo_style($style, str_repeat(' ', $width).PHP_EOL);
128+
}
129+
130+
function has_color_support()
131+
{
132+
static $support;
133+
134+
if (null === $support) {
135+
if (DIRECTORY_SEPARATOR == '\\') {
136+
$support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
137+
} else {
138+
$support = function_exists('posix_isatty') && @posix_isatty(STDOUT);
139+
}
140+
}
141+
142+
return $support;
143+
}

composer.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
1515
},
1616
"autoload-dev": {
17-
"classmap": [ "app/tests/WebTestCase.php" ]
17+
"psr-4": { "Tests\\": "tests/" }
1818
},
1919
"require": {
2020
"php": "^5.5.9|^7.0",
@@ -72,18 +72,15 @@
7272
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
7373
]
7474
},
75-
"config": {
76-
"bin-dir": "bin"
77-
},
7875
"extra": {
7976
"symfony-app-dir": "app",
77+
"symfony-bin-dir": "bin",
78+
"symfony-var-dir": "var",
8079
"symfony-web-dir": "web",
80+
"symfony-tests-dir": "tests",
8181
"symfony-assets-install": "relative",
8282
"incenteev-parameters": [
83-
{
84-
"file": "app/config/parameters.yml",
85-
"env-map": {}
86-
},
83+
{ "file": "app/config/parameters.yml" },
8784
{
8885
"file": "app/config/phpcr.yml",
8986
"dist-file": "app/config/phpcr_doctrine_dbal.yml.dist"

0 commit comments

Comments
 (0)