致命错误:找不到“类”Doctrine \ Common \ Cache \ ArrayCache'。 Composer无法正常工作

时间:2017-06-10 21:30:40

标签: doctrine-orm composer-php

我肯定一个月没有问题。突然间,我开始得到关于缺少类的错误(尽管它们存在),尽管我没有改变任何东西。最后,我重新安装了作曲家和供应商。

有时我收到错误Class 'core\SomeClass' not found in <..>htdocs\type705c\src\bootstrap.php on line 310

有时候,在C:\ Bitnami \ wampstack-5.6.30-2 \ apache2 \ htdocs \ type705c \ src \ bootstrap中找不到ArrayCache' not found. Fatal error:类'Doctrine \ Common \ Cache \ ArrayCache'的学说中出现错误。第258行的php`

但是错误仍然存​​在(或者找不到类,或者找不到“ArrayCache”。我只是保留了删除的vendor / composer目录,有时会出现一个或另一个错误。)

一个班级存在于 \厂商\教义\缓存\ lib中\学说\共同\缓存\ ArrayCache.php

SomeClass类退出\ core

bootstrap.php中

 <..> 

    use Doctrine\ORM\Tools\Setup;
    use Doctrine\ORM\EntityManager;
    use Doctrine\ORM\Configuration;
    use Symfony\Component\Console\Application;
    use Doctrine\Common\Cache\ArrayCache;
    use Doctrine\Common\Cache\ApcCache;


    $entitiesPaths = array( __DIR__.'/Bundle/Entity' );
    $proxiesPaths = array( __DIR__.'/Bundle/Proxies' );


    if ($isDevMode) {
        $cache = new \Doctrine\Common\Cache\ArrayCache;
    } else {
        $cache = new \Doctrine\Common\Cache\ApcCache;
    }

    $config = new Configuration;
    $config->setMetadataCacheImpl($cache);
    $driverImpl = $config->newDefaultAnnotationDriver($entitiesPaths);
    $config->setMetadataDriverImpl($driverImpl);
    $config->setQueryCacheImpl($cache);
    $config->setProxyDir($proxiesPaths);
    $config->setProxyNamespace('DoctrineProxies\__CG__\Bundle\Proxies');

    if ($isDevMode) {
        $config->setAutoGenerateProxyClasses(true);
    } else {
        $config->setAutoGenerateProxyClasses(false);
    }
    <..>

$some='some';
echo "<br> 307 ".$some; //echoes if ArrayCache is found, else do not 

use core\SomeClass;
$ecind = new SomeClass(); 


At this point, if there is no errors with ArrayCache, arose error that core\SomeClass.php  is missing, and i do not see it in autoload_static.php, thus it is really missing. 

我总是使用相同的composer dump-autoload来生成名称空间。

autoload_static.php(如果找不到`ArrayCache'。)     

    // autoload_static.php @generated by Composer

    namespace Composer\Autoload;

    class ComposerStaticInita89eb0d2fe0809574fc31efca00ceb2f
    {
        public static $prefixLengthsPsr4 = array (
            'c' => 
            array (
                'core\\' => 5,
            ),
            'R' => 
            array (
                'RedeyeVentures\\GeoPattern\\SVGElements\\' => 38,
                'RedeyeVentures\\GeoPattern\\' => 26,
            ),
            'L' => 
            array (
                'Bundle\\Resources\\Fnc\\' => 24,
                'Bundle\\Entity\\' => 17,
            ),
            'D' => 
            array (
                'DoctrineProxies\\__CG__\\Bundle\\Entity\\' => 40,
            ),
        );

        public static $prefixDirsPsr4 = array (
            'core\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/core',
            ),
            'RedeyeVentures\\GeoPattern\\SVGElements\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/ComponentsOthers/geopattern-php-master/src/GeoPattern/SVGElements',
            ),
            'RedeyeVentures\\GeoPattern\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/ComponentsOthers/geopattern-php-master/src/GeoPattern',
            ),
            'Bundle\\Resources\\Fnc\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Resources/Fnc',
            ),
            'Bundle\\Entity\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Entity',
            ),
            'Bundle\\DataFixtures\\ownFixtures\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/DataFixtures/ownFixtures',
            ),
            'Bundle\\DataFixtures\\ORM\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/DataFixtures/ORM',
            ),
            'Bundle\\Controller\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Controller',
            ),
            'Bundle\\Components\\StringC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/StringC',
            ),
            'Bundle\\Components\\SocialC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/SocialC',
            ),
            'Bundle\\Components\\HttC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/HttC',
            ),
            'Bundle\\Components\\FormC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/FormC',
            ),
            'Bundle\\Components\\FileC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/FileC',
            ),
            'Bundle\\Components\\ErrC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/ErrC',
            ),
            'Bundle\\Components\\ArrayC\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Components/ArrayC',
            ),
            'DoctrineProxies\\__CG__\\Bundle\\Entity\\' => 
            array (
                0 => __DIR__ . '/../..' . '/src/Bundle/Proxies',
            ),
        );

        public static $prefixesPsr0 = array (
            'M' => 
            array (
                'Migrations' => 
                array (
                    0 => __DIR__ . '/../..' . '/src/migrations',
                ),
            ),
            'L' => 
            array (
                'Bundle\\Entity\\' => 
                array (
                    0 => __DIR__ . '/../..' . '/src/Bundle/Entity',
                ),
            ),
        );

        public static $fallbackDirsPsr0 = array (
            0 => __DIR__ . '/../..' . '/src',
        );

        public static function getInitializer(ClassLoader $loader)
        {
            return \Closure::bind(function () use ($loader) {
                $loader->prefixLengthsPsr4 = ComposerStaticInita89eb0d2fe0809574fc31efca00ceb2f::$prefixLengthsPsr4;
                $loader->prefixDirsPsr4 = ComposerStaticInita89eb0d2fe0809574fc31efca00ceb2f::$prefixDirsPsr4;
                $loader->prefixesPsr0 = ComposerStaticInita89eb0d2fe0809574fc31efca00ceb2f::$prefixesPsr0;
                $loader->fallbackDirsPsr0 = ComposerStaticInita89eb0d2fe0809574fc31efca00ceb2f::$fallbackDirsPsr0;

            }, null, ClassLoader::class);
        }
    }

1 个答案:

答案 0 :(得分:0)

原因是,

我偶然将核心文件夹移动到另一个位置,因此composer.json没有指向正确的文件夹,也找不到类。

而不是/src/core 我偶然从/src移动到/core