8

我在Symfony 2.1中創建新項目。我想檢查我的應用程序是否會在我的服務器上正確運行,因此我複製了所有文件,清除了緩存並設置了權限。 本地的開發環境一切正常,但是當我請求「在線 - 正式版」我的服務器上的版本我得到一個錯誤:Symfony2 - 在產品環境中找不到的類

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

,我發現關於這個問題的一些信息,但它們都涉及到改變從Symfony \ Bundle到Doctrine \ Bundle和Symfony 2.0的命名空間。

所以我檢查了我的AppKernel.php文件,並且我的包路徑是正確的。

我composer.json樣子:

{ 
"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" 
} 

}

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

我試圖找出其中是一個問題,所以我刪除這個包在AppKernel.php中,我得到了下一個致命錯誤:

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

所以我認爲,我有最後2捆唯一的問題:StofDoctrineExtensionsBundleDoctrineFixturesBundle,其中有composer.json DEV-主版本。在這一點上,我沒有任何進一步的想法。我試圖谷歌這個問題,但90%的問題是關於Symfony的2.0動人的Git倉庫;/

本地開發環境: PHP 5.4.6 的Mysql 5.5.27 的Apache 2.2.22(Fedora的)

而我的服務器ENV: PHP 5.4.6 的MySQL 5.0.32

任何幫助將不勝感激。

謝謝!

+0

這是否文件(DoctrineFixturesBundle類)實際存在?嘗試運行:php composer.phar更新,並看看問題是否仍然發生 – Cyprian

+0

嗨,我運行compser.phar更新,我有一些錯誤「源目錄有未提交的更改」。所以我刪除了這些衝突的供應商,一切都很順利。腳本沒有更新任何fixtures/stof包。下一步是將更改複製到在線服務器,並複製整個應用程序目錄。刪除緩存後,我的應用程序在聯機服務器上運行良好,我不知道問題出在哪裏; /感謝您的幫助和建議:) –

回答

-2

應用程序/ 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; 
7

你需要更新/安裝作曲家之前設置的環境中生產的命令行也是如此。

這裏從官方的Symfony文檔

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.

+1

這是正確的答案,但它是一個恥辱,作曲家只是不工作Symfony在製作中...... –