Laravelcollective/html 在 Laravel 5.5 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46392542/
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-09-14 16:43:01  来源:igfitidea点击:

Laravelcollective/html not working in Laravel 5.5

phplaravellaravel-5.5

提问by Oluwatoni Adeoye

I've tried to use the Laravelcollective/htmlon laravel 5.5 by loading the v5.4 in my composer.jsonfile but that didn't work. This is the code in the composer.jsonfile:

我试图Laravelcollective/html通过在我的composer.json文件中加载 v5.4来使用laravel 5.5,但这没有用。这是composer.json文件中的代码:

"laravelcollective/html":"^5.4.0",

and loading it into my app configuration file app.php: inside the providers array

并将其加载到我的应用程序配置文件中app.php:在 providers 数组中

Collective\Html\HtmlServiceProvider::class,

But after i used the blade code to create the form it didn't work, here's the blade code.

但是在我使用刀片代码创建表单后它不起作用,这是刀片代码。

{!! Form::open(['route' => 'posts.store']) !!}

{{Form::label('title','Title:')}}

{{Form::text('title', null, array('class' => 'form-control') )}}

{!! Form::close() !!}

回答by emotality

Install laravelcollective/htmlvia Terminal/CMD:

laravelcollective/html通过终端/CMD安装:

composer require laravelcollective/html:^5.5.0

In app/config/app.php, add the following:

在 中app/config/app.php,添加以下内容:

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

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

And in your blade file:

在您的刀片文件中:

{!! Form::open(['route' => 'posts.store']) !!}
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, array('class' => 'form-control')) !!}
{!! Form::close() !!}

回答by Wisdom Agbenu

You can use this command

你可以使用这个命令

composer require --update-with-all-dependencies "laravelcollective/html 5.6.*"... since you are using laravel 5.5 the command to use will be 
composer require "laravelcollective/html 5.5.*"

回答by pseudoanime

You also have to add the following to your alias array:

您还必须将以下内容添加到别名数组中:

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

],

],

回答by stankophp

The syntax you are using is old style.

您使用的语法是旧式的。

{{Form::label('title','Title:')}} 

It needs to be

它需要是

{!! Form::label('title','Title:') !!}

回答by Y. Joy Ch. Singha

You can do it in laravel 5.5 too. Step 1: Install from Command: composer require "laravelcollective/html":"^5.5"

你也可以在 Laravel 5.5 中做到这一点。第 1 步:从命令安装:composer require "laravelcollective/html":"^5.5"

Step 2: After install you have to add providers and aliases in config/app.php file, so let' follow bellow file how to add.

第 2 步:安装后你必须在 config/app.php 文件中添加提供者和别名,所以让我们按照下面的文件如何添加。

Step 2.1:

步骤 2.1:

<?php

'providers' => [

    // ...

    Collective\Html\HtmlServiceProvider::class,

    // ...

  ],

'aliases' => [

    // ...

      'Form' => Collective\Html\FormFacade::class,

      'Html' => Collective\Html\HtmlFacade::class,

    // ...

  ],

Step 3: After added above providers, you have to check on your project.

第 3 步:添加上述提供程序后,您必须检查您的项目。

Step 4: Done.

第 4 步:完成。

Thanks.

谢谢。

回答by Amranur Rahman

it Simple use this one:

它简单地使用这个:

composer require laravelcollective/html