Deploy Symfony2 application to prod environment causes post-install-cmd exception - php

I have read Symfony2 docs for How to deploy a Symfony2 application but I'm having some issues|warnings. As said here the first command I run is this one:
composer install --no-dev --optimize-autoloader
That command uninstall|erase Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle and I got this error at console:
Generating optimized autoload files
PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /var/www/sis-php-source/app/AppKernel.php on line 40
PHP Stack trace:
PHP 1. {main}() /var/www/sis-php-source/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /var/www/sis-php-source/app/console:28
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/sis-php-source/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
PHP 4. Symfony\Component\HttpKernel\Kernel->boot() /var/www/sis-php-source/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
PHP 5. Symfony\Component\HttpKernel\Kernel->initializeBundles() /var/www/sis-php-source/app/bootstrap.php.cache:2343
PHP 6. AppKernel->registerBundles() /var/www/sis-php-source/app/bootstrap.php.cache:2513
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
These are the contents of the files involved on this (composer.json and AppKernel.php)
composer.json
{
"name": "Sis-PHP-Sources",
"license": "MIT",
"type": "project",
"description": "Sis-PHP-Sources",
"autoload": {
"psr-4": {
"": "src/"
}
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.6",
"doctrine/orm": "~2.2,>=2.2.3",
"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",
"sensio/framework-extra-bundle": "~3.0",
"friendsofsymfony/user-bundle": "~2.0#dev",
"friendsofsymfony/jsrouting-bundle": "2.0.*#dev",
"friendsofsymfony/rest-bundle": "1.6.*#dev",
"jms/serializer-bundle": "0.13.*#dev",
"nelmio/api-doc-bundle": "2.7.*#dev",
"jms/di-extra-bundle": "1.5.*#dev",
"jms/security-extra-bundle": "dev-master",
"knplabs/knp-paginator-bundle": "2.4.*#dev",
"knplabs/knp-menu": "2.0.*#dev",
"knplabs/knp-menu-bundle": "2.0.*#dev",
"stof/doctrine-extensions-bundle": "1.2.*#dev",
"misd/phone-number-bundle": "~1.0",
"willdurand/js-translation-bundle": "2.2.0",
"vich/uploader-bundle": "1.0.*#dev",
"javiereguiluz/easyadmin-bundle": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"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"
],
"post-update-cmd": [
"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"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.6-dev"
},
"symfony-assets-install": "symlink"
}
}
AppKernel.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 Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new FOS\UserBundle\FOSUserBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new Misd\PhoneNumberBundle\MisdPhoneNumberBundle(),
new Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
new Vich\UploaderBundle\VichUploaderBundle(),
new JavierEguiluz\Bundle\EasyAdminBundle\EasyAdminBundle(),
#Sis-PHP Bundles
new AppBundle\AppBundle(),
new Sencamer\BackendBundle\BackendBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
}
}
What I'm doing wrong? Is not that the right way to deploy a Symfony2 application? How I can fix that issue?

Have you read the info box on the documentation page?
If you get a "class not found" error during this step, you may need to
run export SYMFONY_ENV=prod before running this command so that the
post-install-cmd scripts run in the prod environment.

Related

Composer autoloader not working

I'll be as concise and precise as I can. I am thankful for all help!
My system: Symfony 3.3.8, PHP 5.6.25. IDE : PhpStorm
Error encountered :
Attempted to load class "GuzzleBundle" from namespace "EightPoints\Bundle\GuzzleBundle".
Did you forget a "use" statement for another namespace?
My other third-party bundles, KnPMenu or FOSUser, work perfectly.
All these bundles have been installed with composer require (packagist), composer update and then added in AppKernel.
This error pops up on every page of the website as soon as I add the new EightPoints\Bundle\GuzzleBundle\GuzzleBundle(),in the AppKernel.
I tried to composer dump-autoload after this process, but to no avail. I also added the bundle configuration in app/confing/config.yml.
Here are my files :
AppKernel.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
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 EightPoints\Bundle\GuzzleBundle\GuzzleBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new FOS\UserBundle\FOSUserBundle(),
new AppBundle\AppBundle(),
new BaseBundle\BaseBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
}
}
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)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
composer.json
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": {
"AppBundle\\": "src/AppBundle",
"BaseBundle\\": "src/BaseBundle"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=5.5.9",
"components/jquery": "^3.1",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"eightpoints/guzzle-bundle": "^6.1",
"friendsofsymfony/user-bundle": "~2.0",
"incenteev/composer-parameter-handler": "^2.0",
"knplabs/knp-menu-bundle": "^2.0",
"oyejorge/less.php": "v1.7.0.14",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/assetic-bundle": "^2.8",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.8",
"twbs/bootstrap": "^3.3",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"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": [
"#symfony-scripts"
]
},
"config": {
"platform": {
"php": "5.6.25"
},
"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"
},
"branch-alias": {
"dev-master": "3.3-dev"
}
}
}
I don't know why I get this error when I try to use this bundle, please help me!
Error resolved. Seems like PhpStorm excluded vendor folder.
So, vendors were not uploaded to server (wamp64/www).
Vendors were in my local project file by the way... sadly.
After a full upload of vendors in the server, everything seems to work.
Is it normal ? Have I done a begginer mistake ?
Thank you alot four your fast help guys !

Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle' in /app/AppKernel.php

I am new to Symfony.
Trying to install sonata admin bundle.
form:
http://symfony.com/doc/current/bundles/SonataAdminBundle/getting_started/installation.html
But I got an error at
Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle' not found in /home/ubuntu/workspace/app/AppKernel.php
My AppKernel.php's code is
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
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 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
// These are the other bundles the SonataAdminBundle relies on
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
// And finally, the storage and SonataAdminBundle
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], 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();
}
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)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
like this
and composer.json's code is
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" },
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" }
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.1.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"sonata-project/admin-bundle": "^3.4"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"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::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::prepareDeploymentTarget"
]
},
"config": {
"platform": {
"php": "5.5.9"
}
},
"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"
},
"branch-alias": {
"dev-master": "3.1-dev"
}
}
}
Thanks in Advance:
For me, it was exactly as the error had said, the line
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
was repeated twice in AppKernel.php
I think you miss requiring the bundle in composer...
try run
php composer.phar require sonata-project/doctrine-orm-admin-bundle
and composer install / update
From the sonata-admin documentation:
SonataAdminBundle is storage agnostic, meaning it can work with several storage mechanisms. Depending on which you are using on your project, you’ll need to install one of the following bundles. In the respective links you’ll find simple installation instructions for each of them:
More here: https://sonata-project.org/bundles/admin/master/doc/reference/installation.html
Good luck

ClassNotFoundException in AppKernel.php line 25:

Hi when I'm trying to load my symfony 2 app this issue comes,
ClassNotFoundException in AppKernel.php line 25: Attempted to load class "SonataDoctrineORMAdminBundle" from namespace "Sonata\DoctrineORMAdminBundle".
Did you forget a "use" statement for another namespace?
This is my AppKernel.php file,
<?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 kcc\AdminBundle\kccAdminBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), 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();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
This composer.json file,
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": {
"": "src/",
"Sonata\\DoctrineORMAdminBundle\\": ""
}
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"jms/serializer-bundle": "*",
"weaverryan/derp-dangerzone": "dev-master",
"vimuths123/menucreator": "dev-master",
"sonata-project/admin-bundle": "^3.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.0",
"sensio/generator-bundle": "2.3.*",
"sonata-project/user-bundle": "^2.2",
"friendsofsymfony/rest-bundle": "^1.7",
"nelmio/api-doc-bundle": "^2.12",
"sonata-project/core-bundle": "^3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"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::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::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.3.9"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/vimuths123/menucreator"
}
]
}
I tried to update composer also but it's also unable due to this issue
First things First. Are you sure your composer.json file contain the following entries marked <== IMPORTANT:
"require": {
"php": "^5.3 || ^7.0",
"doctrine/orm": "^2.3",
"symfony/form": "^2.3 || ^3.0",
"symfony/security": "^2.3 || ^3.0",
"symfony/console": "^2.3 || ^3.0",
"symfony/doctrine-bridge": "^2.2 || ^3.0",
"symfony/framework-bundle": "^2.2 || ^3.0",
"symfony/security-acl": "^2.2 || ^3.0",
"sonata-project/exporter": "^1.3.1",
"sonata-project/admin-bundle": "^3.0", // <== IMPORTANT
"sonata-project/core-bundle": "^3.0" // <== IMPORTANT
},
"require-dev": {
"simplethings/entity-audit-bundle": "~0.1",
"symfony/phpunit-bridge": "^2.7 || ^3.0"
},
"suggest": {
"simplethings/entity-audit-bundle": "If you want to support for versioning of entities and their associations."
},
"provide": {
"sonata-project/admin-bundle-persistency-layer": "1.0.0"
},
"autoload": {
"psr-4": { "Sonata\\DoctrineORMAdminBundle\\": "" } // <== GOOD TO ADD
},
as it is written in the documentation, you have to install the SonataDoctrineORMAdminBundle by composer:
composer require sonata-project/doctrine-orm-admin-bundle
If you follow the instructions on the symfony page it might help.
Just run this command
composer install/update

Symfony - ClassNotFoundException in app_dev.php

In my local version works normally, but when I put on the server, has this problem! Please help.
ERROR
ClassNotFoundException in app_dev.php line 27:
Attempted to load class "AppKernel" from the global namespace.
Did you forget a "use" statement for e.g. "Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel" or "Symfony\Bundle\SecurityBundle\Tests\Functional\app\AppKernel"?
My app_dev.php :
<?php
use Symfony\Component\HttpFoundation\Request;
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
//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')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
My AppKernel.php
<?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 UserBundle\UserBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Lunetics\LocaleBundle\LuneticsLocaleBundle(),
# New reference upload
new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
new FM\ElfinderBundle\FMElfinderBundle(),
new Sonata\SeoBundle\SonataSeoBundle(),
# Routing translate
#new BeSimple\I18nRoutingBundle\BeSimpleI18nRoutingBundle(),
);
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');
}
}
My autoload.php:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
/**
* #var ClassLoader $loader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
My composer.json:
{
"name": "pedrorossi/dragoes.das.gerais",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/",
"SymfonyStandard\\": "app/SymfonyStandard/"
}
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "2.0.*#dev",
"sonata-project/doctrine-extensions": "*",
"stof/doctrine-extensions-bundle": "^1.2",
"egeloen/ckeditor-bundle": "~2.0",
"helios-ag/fm-elfinder-bundle": "~2.3",
"sonata-project/seo-bundle": "1.1.4",
"lunetics/locale-bundle": "^2.4",
"besimple/i18n-routing-bundle": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"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"
}
}
}
It looks like you're using your app/boostrap.php.cache file as the autoload, please change the following line
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
to
$loader = require __DIR__.'/../app/autoload.php';
Please also make sure that the following code exists in your composer.json file
"autoload": {
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},

Symfony, Tutorial, Creating a Basic CMS using the RoutingAutoBundle

I am making simple Symfony CMS tutorial from:
http://symfony.com/doc/master/cmf/tutorial/introduction.html
http://symfony.com/doc/master/cmf/tutorial/getting-started.html
http://symfony.com/doc/master/cmf/tutorial/auto-routing.html
The problem is that although command line does not show any mistakes, but the fixtures are not loaded and routes are not generated.
Where is my mistake? I follow tutorial exactly, except the installation, because it does not work for me. I installed instead standard-edition of Symfony CMS and created BasicCmsBundle in it.
1)
c:\Bitnami\wampstack-5.4.38-0\sym_prog\standard-edition>php app/console doctrine
:phpcr:fixtures:load
Careful, database will be purged. Do you want to continue Y/N ?y
> purging database
> Executing initializer: CmfContentBundle
> Executing initializer: CmfSimpleCmsBundle Homepage
> Executing initializer: CmfBlockBundle
> Executing initializer: CmfMenuBundle
> Executing initializer: My custom initializer
> loading Acme\BasicCmsBundle\DataFixtures\PHPCR\LoadPageData
> loading Acme\BasicCmsBundle\DataFixtures\PHPCR\LoadPostData
If i check database:
C:\Bitnami\wampstack-5.4.38-0\sym_prog\standard-edition\app\app.sqlite
- it is empty, there are no posts and pages.
2) And the command below does not list routes.
c:\Bitnami\wampstack-5.4.38-0\sym_prog\standard-edition>php app/console doctrine
:phpcr:node:dump
ROOT:
cms:
content:
blocks:
hero_unit:
quick_tour:
configure:
demo:
simple:
home:
demo:
quick_tour:
login:
menu:
pages:
Home:
posts:
My First Post:
My Second Post:
My Third Post:
My Fourth Post:
routes:
3) Actually the tutorial does not show where and how to create resources for the fixtures. Maybe you could tell in short how web pages (resources) are generated in CMS for the given document and fixtures.
composer.json
{
"name": "symfony-cmf/standard-edition",
"homepage": "http://cmf.symfony.com",
"license": "MIT",
"type": "project",
"description": "The \"Symfony CMF Standard Edition\" distribution",
"authors": [
{
"name": "Symfony CMF Community",
"homepage": "https://github.com/symfony-cmf/standard-edition/contributors"
}
],
"autoload": {
"psr-0": { "": "src/" }
},
"minimum-stability": "stable",
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.5",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/data-fixtures": "~1.0",
"doctrine/doctrine-cache-bundle": "~1.0",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"symfony-cmf/symfony-cmf": "1.2.*",
"symfony-cmf/simple-cms-bundle": "1.2.*",
"symfony-cmf/menu-bundle" : "~1.2",
"symfony-cmf/tree-browser-bundle": "~1.1",
"symfony-cmf/create-bundle": "1.2.*",
"symfony-cmf/routing-auto-bundle": "~1.0",
"symfony-cmf/routing-bundle": "~1.3",
"symfony-cmf/routing": "~1.3",
"jackalope/jackalope-doctrine-dbal": "1.1.*",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"nelmio/alice": "~1.0",
"sonata-project/doctrine-phpcr-admin-bundle" : "~1.2"
},
"require-dev": {
"liip/functional-test-bundle": "~1.0",
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Symfony\\Cmf\\Bundle\\CreateBundle\\Composer\\ScriptHandler::downloadCreateAndCkeditor",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Symfony\\Cmf\\Bundle\\CreateBundle\\Composer\\ScriptHandler::downloadCreateAndCkeditor",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "1.2-dev"
}
}
}
C:\Bitnami\wampstack-5.4.38-0\sym_prog\standard-edition\app\AppKernel.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// Symfony Standard Edition Bundles
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(),
// Symfony CMF Standard Edition Bundles
new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
new Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
new Symfony\Cmf\Bundle\ContentBundle\CmfContentBundle(),
new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
new Symfony\Cmf\Bundle\RoutingAutoBundle\CmfRoutingAutoBundle(),
new Symfony\Cmf\Bundle\SimpleCmsBundle\CmfSimpleCmsBundle(),
new Symfony\Cmf\Bundle\BlockBundle\CmfBlockBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Symfony\Cmf\Bundle\CreateBundle\CmfCreateBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
// Remove this Bundle when using the SE as the basis for a new project
new Acme\DemoBundle\AcmeDemoBundle(),
new Acme\TaskBundle\AcmeTaskBundle(),
new Acme\BasicCmsBundle\AcmeBasicCmsBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$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(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
}
C:\Bitnami\wampstack-5.4.38-0\sym_prog\standard-edition\app\config\parameters.yml
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_sqlite
database_host: null
database_port: null
database_name: standard
database_user: admin
database_password: gintare
database_path: '%kernel.root_dir%/app.sqlite'
phpcr_backend:
type: doctrinedbal
connection: default
caches:
meta: doctrine_cache.providers.phpcr_meta
nodes: doctrine_cache.providers.phpcr_nodes
phpcr_workspace: default
phpcr_user: admin
phpcr_password: admin
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
debug_toolbar: true
debug_redirects: false
use_assetic_controller: true
The rest of files are copies from the Tutorial website. If you ask i will paste them:
C:\Bitnami\wampstack-5.4.38-0\sym_prog\standard-edition\
src\Acme\BasicCmsBundle\Document\ContentTrait.php
\src\Acme\BasicCmsBundle\Document\Page.php
src\Acme\BasicCmsBundle\Document\Post.php
src\Acme\BasicCmsBundle\DataFixtures\PHPCR\LoadPageData.php
src\Acme\BasicCmsBundle\DataFixtures\PHPCR\LoadPostData.php
src\Acme\BasicCmsBundle\Resources\config\cmf_routing_auto.yml
<?php
// src/Acme/BasicCmsBundle/DataFixtures/PHPCR/LoadPageData.php
namespace Acme\BasicCmsBundle\DataFixtures\PHPCR;
use Acme\BasicCmsBundle\Document\Page;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\PHPCR\DocumentManager;
class LoadPageData implements FixtureInterface
{
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}
$parent = $dm->find(null, '/cms/pages');
$page = new Page();
$page->setTitle('Home');
$page->setParentDocument($parent);
$page->setContent(<<<HERE
Welcome to the homepage of this really basic CMS.
HERE
);
$dm->persist($page);
$dm->flush();
}
}

Categories