Laravel 5.1: Class html 不存在
Laravel 5.1: Class html does not exist
我正在从 4.2 直接升级到 5.1,运行 遇到 Html 和表格 classes 的问题。
我按照升级说明做了
- 添加 "laravelcollective/html": "~5.0" 到 composer.json
- 作曲家更新
- 将 Collective\Html\HtmlServiceProvider::class 添加到 app.php
中的提供商
- 添加表格' => Collective\Html\FormFacade::class,
Html' => Collective\Html\HtmlFacade::class 到 app.php
中的别名
但是我的观点行不通。我在使用 HTML::router 时得到 Class HTML does not exist
或在使用 link_to_route
时得到 Class html does not exist
我也试过 Illuminate\html
而不是 laravelcollective
,我做了 composer dump-autoload
。
完整的错误:
ErrorException in Container.php line 736: Class html does not exist (View: C:\Dev\www\admin\resources\views\clubs\index.blade.php)
ReflectionException in Container.php line 736: Class html does not exist
我错过了什么?
我尝试了每个人的答案,其中 none 出于某种原因对我有用。最终我创建了一个全新的 laravel 应用程序,复制了我的代码然后它开始工作,所以尽管解决了实际问题仍然是个谜。
加入composer.json
"illuminate/html": "5.*"
和运行作曲家更新
打开你的config/app.php
在'providers'下添加
Illuminate\Html\HtmlServiceProvider::class,
在'aliases'下添加
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
并在您的 blade 模板下使用
{!! HTML::style('assets/css/flatten.css') !!}
我的问题解决了,具体原因还不清楚。我创建了一个全新的 laravel 安装并复制了我的源代码(全部)。新应用程序立即运行(安装 illuminate/html 后)。
所以你认为我对包裹做错了什么?我就是这么想的,然后我对两个目录进行了比较,结果发现它们是相同的。所以这是一个真正的谜。
所以,现在一切正常,我只是重命名了我的新应用程序并可以继续。
我确实知道在某些时候我可能同时安装了 HTML 软件包的集体版本和 illuminate 版本。这就是最有可能破坏一切的东西。
作曲家更新后的简单重启非常适合我。我一直在寻找答案,但被困在同一个位置。我建议 运行 config:cache 和 cache:clear 并重新启动 IDE。它会起作用。
我的解决方案是区分大小写的 class 名称。
In my config/app.php (in aliases)
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
我尝试在视图中使用此代码:
{!! HTML::mailto('mailto:example@example.com', 'example@example.com'); !!}
这是一个错误:
"FatalErrorException in ccf70b1d0b9930d6c4e8f3859fff448f line 11: Class 'HTML' not found"
class'HTML' 的名称区分大小写。您应该像在配置 (config/app.php) 文件中那样使用 'Html'。
希望这对某些人有所帮助。
这是正确的方法
如果您尝试在全新 Laravel 5 安装中使用 Form::open() 或任何 Form 方法,您将得到如下内容:
http://laraveldaily.com/class-form-not-found-in-laravel-5/
请从这个
更改您的blade文件
{{ HTML::style('css/bootstrap.min.css') }}
到
{{ Html::style('css/bootstrap.min.css') }}
有效。
我想我已经找到了解决办法。
在您的 app.php
中您已声明
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
虽然在您的 View
中您调用了与
相同的 class
{!! HTML::style('css/bootstrap.min.css') !!}
与上面标记的答案一样,这些包没有任何问题,但 HTML
这个词的大小写与之前的文档版本 5.0.*.
不同
应该是
'Form' => Illuminate\Html\FormFacade::class,
'HTML' => Illuminate\Html\HtmlFacade::class,
试一试
php artisan cache:clear
php artisan clear-compiled
编辑config/app.php
将此添加到 提供商
Collective\Html\HtmlServiceProvider::class,
并将其转化为 别名
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
我正在从 4.2 直接升级到 5.1,运行 遇到 Html 和表格 classes 的问题。
我按照升级说明做了
- 添加 "laravelcollective/html": "~5.0" 到 composer.json
- 作曲家更新
- 将 Collective\Html\HtmlServiceProvider::class 添加到 app.php 中的提供商
- 添加表格' => Collective\Html\FormFacade::class, Html' => Collective\Html\HtmlFacade::class 到 app.php 中的别名
但是我的观点行不通。我在使用 HTML::router 时得到 Class HTML does not exist
或在使用 link_to_route
Class html does not exist
我也试过 Illuminate\html
而不是 laravelcollective
,我做了 composer dump-autoload
。
完整的错误:
ErrorException in Container.php line 736: Class html does not exist (View: C:\Dev\www\admin\resources\views\clubs\index.blade.php)
ReflectionException in Container.php line 736: Class html does not exist
我错过了什么?
我尝试了每个人的答案,其中 none 出于某种原因对我有用。最终我创建了一个全新的 laravel 应用程序,复制了我的代码然后它开始工作,所以尽管解决了实际问题仍然是个谜。
加入composer.json
"illuminate/html": "5.*"
和运行作曲家更新
打开你的config/app.php
在'providers'下添加
Illuminate\Html\HtmlServiceProvider::class,
在'aliases'下添加
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
并在您的 blade 模板下使用
{!! HTML::style('assets/css/flatten.css') !!}
我的问题解决了,具体原因还不清楚。我创建了一个全新的 laravel 安装并复制了我的源代码(全部)。新应用程序立即运行(安装 illuminate/html 后)。
所以你认为我对包裹做错了什么?我就是这么想的,然后我对两个目录进行了比较,结果发现它们是相同的。所以这是一个真正的谜。
所以,现在一切正常,我只是重命名了我的新应用程序并可以继续。
我确实知道在某些时候我可能同时安装了 HTML 软件包的集体版本和 illuminate 版本。这就是最有可能破坏一切的东西。
作曲家更新后的简单重启非常适合我。我一直在寻找答案,但被困在同一个位置。我建议 运行 config:cache 和 cache:clear 并重新启动 IDE。它会起作用。
我的解决方案是区分大小写的 class 名称。
In my config/app.php (in aliases)
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
我尝试在视图中使用此代码:
{!! HTML::mailto('mailto:example@example.com', 'example@example.com'); !!}
这是一个错误:
"FatalErrorException in ccf70b1d0b9930d6c4e8f3859fff448f line 11: Class 'HTML' not found"
class'HTML' 的名称区分大小写。您应该像在配置 (config/app.php) 文件中那样使用 'Html'。
希望这对某些人有所帮助。
这是正确的方法 如果您尝试在全新 Laravel 5 安装中使用 Form::open() 或任何 Form 方法,您将得到如下内容: http://laraveldaily.com/class-form-not-found-in-laravel-5/
请从这个
更改您的blade文件{{ HTML::style('css/bootstrap.min.css') }}
到
{{ Html::style('css/bootstrap.min.css') }}
有效。
我想我已经找到了解决办法。
在您的 app.php
中您已声明
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
虽然在您的 View
中您调用了与
{!! HTML::style('css/bootstrap.min.css') !!}
与上面标记的答案一样,这些包没有任何问题,但 HTML
这个词的大小写与之前的文档版本 5.0.*.
应该是
'Form' => Illuminate\Html\FormFacade::class,
'HTML' => Illuminate\Html\HtmlFacade::class,
试一试
php artisan cache:clear
php artisan clear-compiled
编辑config/app.php
将此添加到 提供商
Collective\Html\HtmlServiceProvider::class,
并将其转化为 别名
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,