Laravel 5 Class 'Collective\Html\HtmlServiceProvider' 未在 AWS 上找到

Laravel 5 Class 'Collective\Html\HtmlServiceProvider' not found on AWS

我知道还有很多其他问题存在同样的错误,例如:

我的问题是我已经按照所有建议的步骤在我的本地 (XAMPP) 上解决了这个问题,并且它顺利地修复了它。问题是当我去部署到我的 AWS ubuntu 框 (nginx) 时。我遵循了所有常规说明:http://laravelcollective.com/docs/5.1/html#installation

我的提供商和别名是在我从我从本地推送的内容中提取 git 时添加的。也许应该 git 忽略此文件,并在服务器上手动进行更改?

Next, add your new provider to the providers array of config/app.php:

  'providers' => [
    // ...
    Collective\Html\HtmlServiceProvider::class,
    // ...
  ],

Finally, add two class aliases to the aliases array of config/app.php:

  'aliases' => [
    // ...
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,
    // ...
  ],

然后我手动添加:

Begin by installing this package through Composer. Edit your project's composer.json file to require laravelcollective/html.

"require": {
    "laravelcollective/html": "5.1.*"
}

最后,我 运行:

composer.phar update

正是 运行 这个命令引发了错误:

PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
> php artisan clear-compiled
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
PHP Fatal error:  Class 'Collective\Html\HtmlServiceProvider' not found in /usr/share/nginx/html/cbt/vendor/compiled.php on line 6



  [Symfony\Component\Debug\Exception\FatalErrorException]
  Class 'Collective\Html\HtmlServiceProvider' not found



Script php artisan clear-compiled handling the pre-update-cmd event returned with an error



  [RuntimeException]
  Error Output: PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
  PHP Fatal error:  Class 'Collective\Html\HtmlServiceProvider' not found in /usr/share/nginx/html/cbt/vendor/compiled.php on line



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-auties] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ...

然后我尝试了 运行 php artisan clear-compiled,看看它是否会做任何事情,并得到:

PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
PHP Fatal error:  Class 'Collective\Html\HtmlServiceProvider' not found in /usr/share/nginx/html/cbt/vendor/compiled.php on line 6716



  [Symfony\Component\Debug\Exception\FatalErrorException]
  Class 'Collective\Html\HtmlServiceProvider' not found

我知道我的 nginx ubuntu 环境与 windows xampp 环境不同,但我仍然不确定为什么要遵循 Laravel 提供的说明添加这个似乎不起作用。非常感谢对此的一些建议。

干杯!

当您更新作曲家时,它会检查供应商。因为你还没有安装 laravelcollective/html 而他找不到并抛出错误:

所以首先需要你的包,然后将它们添加到配置文件中。

您也可以使用 composer require laravelcollective/html,它会自动将其添加到 json 文件中。那么之前是否添加过都没有关系,因为不会检查配置文件。

我在 Laravel 5.2 上遇到了同样的错误。*,按照此处的说明进行操作:https://laravelcollective.com/docs/5.2/html,但没有成功。

另一种修复方法,在您的 CLI 上,运行:

$作曲家转储自动加载

然后运行:

$作曲家更新

这对我有用。 ;)

如果您使用的是 Laravel 5.2,请尝试将其添加到您的 composer.json

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "laravelcollective/html": "^5.2",
    ... 
},

安装失败,./composer.json 恢复到原来的内容。

[ErrorException]
copy(/home/zahid/.composer/cache/files/laravelcollective/html/20e9e29d83e23aba16dc4b8d93d0757e1541f076.zip): failed to open stream: Permiss ion denied

命令:composer require laravelcollective/html --prefer-source

然后就可以了

首先尝试 composer 更新。它将更新所有依赖项,但如果它不起作用,请删除项目的供应商文件夹并在 cli 中键入 composer install 和 运行 再次添加依赖项。