2016-04-08 9 views
1

私のローカルバージョンでは正常に動作しますが、サーバを置くとこの問題が発生します。助けてください。 app_dev.phpライン27でsymfony - ClassNotFoundException in app_dev.php

ERROR

にClassNotFoundException: は、グローバルな名前空間からクラス "AppKernel" をロードしようとしました。 たとえば、「使用」ステートメントを忘れましたか? "Symfony \ Bundle \ FrameworkBundle \ Tests \ Functional \ app \ AppKernel"または "Symfony \ Bundle \ SecurityBundle \ Tests \ Functional \ app \ AppKernel"のいずれかを選択します。

マイ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); 

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

マイ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; 

マイ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" 
    } 
} 
} 
+0

あなたの冒頭に空白があるのは正常ですかAppKernelファイルですか? –

+0

また、サーバでPHPUnitを実行しているので、 'app/phpunit.xml.dist'ファイルをチェックして、' Kernel'情報が適切に設定されていることを確認する必要があります –

答えて

2

それはまたことを確認してくださいあなたが自動ロードとしてあなたのアプリ/ boostrap.php.cacheファイルを使用しているように、

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

に次の行

$loader = require_once __DIR__.'/../app/bootstrap.php.cache'; 

を変更してくださいに見えます次のコードがあなたのcomposer.jsonファイルに存在します

"autoload": { 
    "classmap": [ 
     "app/AppKernel.php", 
     "app/AppCache.php" 
    ] 
    }, 
関連する問題