php 在 AWS 上找不到 Laravel 5 类“Collective\Html\HtmlServiceProvider”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32795154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:11:39  来源:igfitidea点击:

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

phplaravelamazon-web-serviceslaravel-5laravelcollective

提问by carbide20

I know there are a bunch of other questions floating around out there with the same error, such as: Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5

我知道还有一堆其他问题在那里漂浮着相同的错误,例如:Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5

My problem is that I've followed all suggested steps to solve this on my local (XAMPP), and it fixed it without a hitch. The issue is when I went to deploy to my AWS ubuntu box (nginx). I followed all the usual instructions: http://laravelcollective.com/docs/5.1/html#installation

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

My providers and aliases had been added when I did a git pull from what I had pushed from my local. Perhaps this file should have been gitignored, and the change made manually on the server?

当我从本地推送的内容中执行 git pull 时,已经添加了我的提供者和别名。也许这个文件应该被 gitignored 忽略,并且在服务器上手动进行了更改?

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,
    // ...
  ],

I then manually added:

然后我手动添加:

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

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

And finally, I ran:

最后,我跑了:

composer.phar update

It was running this command that throws the error:

它正在运行这个抛出错误的命令:

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] ...

I then tried running php artisan clear-compiled, to see if that would do anything, and got:

然后我尝试运行 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

I know my nginx ubuntu environment is not the same as a windows xampp env, but I'm still unsure why following the Laravel-provided instructions for adding this don't seem to working. Would greatly appreciate some advice on this.

我知道我的 nginx ubuntu 环境与 windows xampp env 不同,但我仍然不确定为什么按照 Laravel 提供的说明添加它似乎不起作用。将不胜感激有关此的一些建议。

Cheers!

干杯!

回答by cre8

When you update your composer it will check the providers. Because you haven't installed laravelcollective/htmlyet he can't find it and throws an error:

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

So first require your packeges, then add them to the config file.

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

You can also work with composer require laravelcollective/html, it will add it to the json file automatically. Then it doesn't matter if you have added them before or not because the config file won't be checked.

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

回答by Gengjun Wu

I have encountered the same error on Laravel 5.2.*, followed instruction here: https://laravelcollective.com/docs/5.2/html, but did not work.

我在 Laravel 5.2.* 上遇到了同样的错误,按照这里的说明操作:https://laravelcollective.com/docs/5.2/html ,但没有用。

The other way to fix it, on your CLI, run:

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

$ composer dump-autoload

$作曲家转储自动加载

Then run:

然后运行:

$ composer update

$作曲家更新

This works for me. ;)

这对我有用。;)

回答by ecairol

If you're using Laravel 5.2, try adding this to your composer.json

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

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

回答by Zahid Gani

Installation failed, reverting ./composer.json to its original content.

安装失败,将 ./composer.json 恢复为其原始内容。

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

[ErrorException]
copy(/home/zahid/.composer/cache/files/laravelcollective/html/20e9e29d83e23aba16dc4b8d93d0757e1541f076.zip):无法打开流:权限
被拒绝

Command: composer require laravelcollective/html --prefer-source

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

then it work

然后它工作

回答by Ram Bhandari

First try composer update. It will update all dependencies but in case it doesn't work delete vendor folder of your project and type composer installand run in cli which again add dependencies.

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