-
-
Save webdevilopers/026dc483e3824c0b0a28 to your computer and use it in GitHub Desktop.
<?php | |
use Symfony\Component\HttpKernel\Kernel; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
class AppKernel extends Kernel | |
{ | |
public function registerBundles() | |
{ | |
$bundles = array( | |
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | |
new Symfony\Bundle\SecurityBundle\SecurityBundle(), | |
new Symfony\Bundle\TwigBundle\TwigBundle(), | |
new Symfony\Bundle\MonologBundle\MonologBundle(), | |
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), | |
new Symfony\Bundle\AsseticBundle\AsseticBundle(), | |
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), | |
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), | |
new AppBundle\AppBundle(), | |
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), | |
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), | |
new Craue\FormFlowBundle\CraueFormFlowBundle(), | |
new Gregwar\CaptchaBundle\GregwarCaptchaBundle(), | |
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), | |
new Vich\UploaderBundle\VichUploaderBundle(), | |
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(), | |
#new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle() | |
); | |
if (in_array($this->getEnvironment(), array('dev', 'test'))) { | |
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); | |
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); | |
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); | |
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); | |
} | |
return $bundles; | |
} | |
public function registerContainerConfiguration(LoaderInterface $loader) | |
{ | |
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); | |
} | |
} |
{ | |
"name": "webdeviloper/semcoglas", | |
"license": "proprietary", | |
"type": "project", | |
"autoload": { | |
"psr-0": { | |
"": "src/", | |
"SymfonyStandard": "app/" | |
} | |
}, | |
"require": { | |
"php": ">=5.3.3", | |
"symfony/symfony": "2.6.*", | |
"doctrine/orm": "~2.2,>=2.2.3,<2.5", | |
"doctrine/dbal": "<2.5", | |
"doctrine/doctrine-bundle": "~1.2", | |
"twig/extensions": "~1.0", | |
"symfony/assetic-bundle": "~2.3", | |
"symfony/swiftmailer-bundle": "~2.3", | |
"symfony/monolog-bundle": "~2.4", | |
"sensio/distribution-bundle": "~3.0,>=3.0.12", | |
"sensio/framework-extra-bundle": "~3.0,>=3.0.2", | |
"incenteev/composer-parameter-handler": "~2.0", | |
"craue/formflow-bundle": "dev-master", | |
"doctrine/doctrine-fixtures-bundle": "v2.2.0", | |
"doctrine/migrations": "1.1.0", | |
"doctrine/doctrine-migrations-bundle": "1.0.0", | |
"gregwar/captcha-bundle": "v1.1", | |
"stof/doctrine-extensions-bundle": "v1.1.0", | |
"guzzlehttp/guzzle": "5.3.0", | |
"vich/uploader-bundle": "dev-master", | |
"knplabs/knp-snappy-bundle": "dev-master", | |
"ramsey/uuid": "^3.1" | |
}, | |
"require-dev": { | |
"sensio/generator-bundle": "~2.3", | |
"andres-montanez/magallanes": "~1.0.1" | |
}, | |
"scripts": { | |
"post-root-package-install": [ | |
"SymfonyStandard\\Composer::hookRootPackageInstall" | |
], | |
"post-install-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::removeSymfonyStandardFiles", | |
"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::removeSymfonyStandardFiles", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget" | |
] | |
}, | |
"config": { | |
"bin-dir": "bin" | |
}, | |
"extra": { | |
"symfony-app-dir": "app", | |
"symfony-web-dir": "web", | |
"symfony-assets-install": "relative", | |
"incenteev-parameters": { | |
"file": "app/config/parameters.yml" | |
} | |
} | |
} |
/var/www/semcoweb/current$ php app/console doctrine:schema:update --dump-sql | |
PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /var/www/semcoweb/releases/20151228085906/app/AppKernel.php on line 32 | |
PHP Stack trace: | |
PHP 1. {main}() /var/www/semcoweb/releases/20151228085906/app/console:0 | |
PHP 2. Symfony\Component\Console\Application->run() /var/www/semcoweb/releases/20151228085906/app/console:27 | |
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/semcoweb/releases/20151228085906/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126 | |
PHP 4. Symfony\Component\HttpKernel\Kernel->boot() /var/www/semcoweb/releases/20151228085906/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70 | |
PHP 5. Symfony\Component\HttpKernel\Kernel->initializeBundles() /var/www/semcoweb/releases/20151228085906/app/bootstrap.php.cache:2372 | |
PHP 6. AppKernel->registerBundles() /var/www/semcoweb/releases/20151228085906/app/bootstrap.php.cache:2542 |
Your CLI thinks it is in dev mode.
add this to the .bashrc of your production user : export SYMFONY_ENV="prod"
Of course, you need to source your bashrc again after that.
You are right @greg0ire ! I was running the command after deployment with capistrano. Composer always sets SYMFONY_ENV
too.
Actually I stopped using the command for some time because there were issues when I worked on FreeBSD:
capistrano/symfony#24
In the end those guys used the same workaround - actually solution - you recommended.
I could use the virtual host too, can I?
<VirtualHost *:80>
ServerName symfony.com
DocumentRoot /var/www/symfony/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv SYMFONY_ENV prod
<Directory "/var/www/symfony/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Source: https://gist.github.com/webdevilopers/b8d21112f12fba0e6f62
What's the difference between putting SYMFONY_ENV
in .bashrc
and .profile
as suggested by @m7internet, @greg0ire ?
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-symfony-application-to-production-on-ubuntu-14-04?comment=40781
You can use this in your virtual host, but it is useless IMO because it gets set when you use app.php vs app_dev.php
After reading this, it might be better to use .profile
, but I think the best is to test which gets actually executed when you need it to.
Running the doctrine command in
prod
looks up theSensioGeneratorBundle
by @sensiolabs:In order to make it work in production it has to be moved from
required-dev
torequire
and be permanently enabled in theAppKernel
.Twitter discussion:
https://twitter.com/webdevilopers/status/689181740288634880 @TomasVotruba @greg0ire