【问题标题】:Fatal error: ` Class 'Doctrine\Common\Cache\ArrayCache' not found. Composer is not working properly致命错误:` 类 'Doctrine\Common\Cache\ArrayCache' 未找到。作曲家无法正常工作
【发布时间】:2017-11-12 16:18:13
【问题描述】:

我已经开始收到有关缺少课程的错误(尽管它们存在),但我没有更改任何内容。我已经重新安装了作曲家和供应商。

有时我会收到错误消息:

在第 310 行的 <..>htdocs\type705c\src\bootstrap.php 中找不到类 'core\SomeClass'

有时会出现错误,即找不到教义ArrayCache

致命错误:第 258 行的 C:\Bitnami\wampstack-5.6.30-2\apache2\htdocs\type705c\src\bootstrap.php 中找不到类 'Doctrine\Common\Cache\ArrayCache'

我只是不断删除供应商/作曲家目录,有时会出现一个或另一个错误。

一个类存在于 \vendor\doctrine\cache\lib\Doctrine\Common\Cache\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(); 

此时,如果ArrayCache没有错误,就会出现core\SomeClass.php丢失的错误,而我在autoload_static.php中没有看到它,因此它确实丢失了。

我总是使用同一个 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);
        }
    }

【问题讨论】:

    标签: doctrine-orm composer-php


    【解决方案1】:

    原因是,

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

    而不是/src/core 我不小心从/src 移动到/core

    【讨论】:

      猜你喜欢
      • 2021-10-09
      • 2015-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多