代码之家  ›  专栏  ›  技术社区  ›  eComEvo

在分叉供应商中未找到Laravel服务提供商类

  •  1
  • eComEvo  · 技术社区  · 8 年前

    我正在开发一种回购协议,该协议在拉雷维尔运作良好。当我分叉回购时,我现在得到了这个错误:

    [Symfony\Component\Debug\Exception\FatalThrowableError]
    Class 'DevIT\Hasoffers\Laravel\Providers\HasoffersServiceProvider' not found
    

    我试着在中注释提供者行 app.php ,然后运行这些,然后取消对行的注释,但这些没有帮助:

    composer dump-autoload
    php artisan clear-compiled
    php artisan optimize
    

    这是composer中的配置。json:

    "require": {
        "devit/hasoffers-php-client": "dev-master",
        "devit/hasoffers-laravel-client": "dev-master"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "devit/hasoffers-php-client",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/ecomevo/hasoffers-php.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "devit/hasoffers-laravel-client",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/ecomevo/hasoffers-laravel.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    

    如果我导航到vendor目录,包就在那里,composer声称它在最新的更新中引入了它。

    我做错了什么?

    1 回复  |  直到 8 年前
        1
  •  2
  •   patricus    8 年前

    您的composer文件正在使用 package repositories ,它不会读取 composer.json 正在拉入的包的文件。由于PSR-4自动加载是在这些 创作者json 文件,它没有被设置,并且找不到您的类。

    您可以将自动加载功能添加到包定义中,但最好使用 vcs repository type 创作者json 文件将得到尊重。

    您的composer文件应该类似于:

    "require": {
        "devit/hasoffers-php-client": "dev-master",
        "devit/hasoffers-laravel-client": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ecomevo/hasoffers-php"
        },
        {
            "type": "vcs",
            "url": "https://github.com/ecomevo/hasoffers-laravel"
        }
    ],
    

    由于您已经使用以前的方法拉入了这些包,您可能需要在执行composer更新之前清除composer缓存:

    composer clearcache
    composer update devit/hasoffers-php-client
    composer update devit/hasoffers-laravel-client