我在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捆唯一的問題:StofDoctrineExtensionsBundle和DoctrineFixturesBundle,其中有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
任何幫助將不勝感激。
謝謝!
這是否文件(DoctrineFixturesBundle類)實際存在?嘗試運行:php composer.phar更新,並看看問題是否仍然發生 – Cyprian
嗨,我運行compser.phar更新,我有一些錯誤「源目錄有未提交的更改」。所以我刪除了這些衝突的供應商,一切都很順利。腳本沒有更新任何fixtures/stof包。下一步是將更改複製到在線服務器,並複製整個應用程序目錄。刪除緩存後,我的應用程序在聯機服務器上運行良好,我不知道問題出在哪裏; /感謝您的幫助和建議:) –