8
votes

i am creating new project in Symfony 2.1 . I wanted to check if my application will go correctly on my server, so I copied all files, cleared cache and set permissions. locally in dev environment everything is alright, but when I request "online - prod" version on my server i get an error:

Fatal error: Class 'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle' not found in /www/gastlich_www/www/livescore.gastlich.iq.pl/app/AppKernel.php on line 25

I found some information about this problem, but all of them relates to changing namespace from Symfony\Bundle to Doctrine\Bundle and Symfony 2.0.

So I've checked my AppKernel.php file, and my bundle path was correct.

My composer.json looks like:

{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.1.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "doctrine/doctrine-bundle": "1.0.*",
    "twig/extensions": "1.0.*",
    "symfony/assetic-bundle": "2.1.*",
    "symfony/swiftmailer-bundle": "2.1.*",
    "symfony/monolog-bundle": "2.1.*",
    "sensio/distribution-bundle": "2.1.*",
    "sensio/framework-extra-bundle": "2.1.*",
    "sensio/generator-bundle": "2.1.*",
    "jms/security-extra-bundle": "1.2.*",
    "jms/di-extra-bundle": "1.1.*",
    "stof/doctrine-extensions-bundle": "dev-master",
    "doctrine/doctrine-fixtures-bundle": "dev-master"
},
"scripts": {
    "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"
    ],
    "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"
    ]
},
"minimum-stability": "dev",
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web"
}

}

And AppKernel.php configuration:

<?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 JMS\AopBundle\JMSAopBundle(),
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
            new Acme\StoreBundle\AcmeStoreBundle(),
            new Livescore\StatsBundle\LivescoreStatsBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle()
        );

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

I was trying to figure out where is a problem, so i deleted this bundle in AppKernel.php, and i got next one Fatal Error :

Fatal error: Class 'Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle' not found in /www/gastlich_www/www/livescore.gastlich.iq.pl/app/AppKernel.php on line 24

So I assume, that i have only problem with last 2 bundles : StofDoctrineExtensionsBundle and DoctrineFixturesBundle, which have dev-master versions in composer.json . At this point, i haven't got any further idea. I was trying to google this problem, but 90% of problems was about Symfony 2.0 and moving git repository ;/

Local dev environment: PHP 5.4.6 Mysql 5.5.27 Apache 2.2.22 (Fedora)

And my server env: PHP 5.4.6 MySql 5.0.32

Any help will be appreciated.

Thanks!

2
Does this file (with DoctrineFixturesBundle class) physically exist? Try run: php composer.phar update, and see if problem still happensCyprian
Hi, i run compser.phar update and i've got some errors with "Source directory has uncommitted changes". So I deleted these conflicted vendors and everything went well. Script didn't update any of fixtures/stof bundle. Next step was to copy changes to online server and I copied entire application directory. After deleting cache, my application is running well on online server and i don't know where was the problem ;/ Thanks for your help and suggest :)Jacek Wojna

2 Answers

7
votes

You need to set the environment to production for the command line as well before updating/installing composer.

Here from the official Symfony documentation:

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.

-2
votes

app/autoload.php

use Doctrine\Common\Annotations\AnnotationRegistry;

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

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

    $loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}

$loader->add('Stof\DoctrineExtensionsBundle', __DIR__.'/../vendor/stof/doctrine-extensions-bundle');
$loader->add('Gedmo' , __DIR__.'/../vendor/gedmo/doctrine-extensions/lib');

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

return $loader;