Laravel 5:在不使用Composer的情况下安装Form和HTML类 [英] Laravel 5: Installing Form and HTML classes without composer
问题描述
我有兴趣在没有作曲家的情况下在Laravel 5上安装Form和HTML类. 我该怎么办?
I'm interested in installing Form and HTML classes on Laravel 5 without composer. How can I do this?
对于那些想说服我使用作曲家的人:
For those wanting to convince me to use composer:
1)我想通过自己至少手动执行一次来查看它的作用.
1) I want to see what it does by doing it manually myself at least once.
2)我的主机上没有作曲家.
2) There is no composer on my hosting.
3)使用composer.phar会引发错误:Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
,并给出警告:Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
和运行时异常,并输出空白错误.
3) Using composer.phar throws an error: Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
, gives a warning: Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
and runtime exception with blank error output.
推荐答案
安装laracollective/html:
2)解压缩内容并创建此目录结构:laravelcollective/html/{contents of html-5.1 directory}
2) Unpack contents and create this directory structure: laravelcollective/html/{contents of html-5.1 directory}
3)将此结构复制到Laravel安装中的供应商文件夹中.
3) Copy this structure to the vendor folder in your Laravel installation.
4)在vendor/composer/autoload_classmap.php
中添加这些行
'Collective\\Html\\FormBuilder' => $vendorDir . '/laravelcollective/html/src/FormBuilder.php',
'Collective\\Html\\FormFacade' => $vendorDir . '/laravelcollective/html/src/FormFacade.php',
'Collective\\Html\\HtmlBuilder' => $vendorDir . '/laravelcollective/html/src/HtmlBuilder.php',
'Collective\\Html\\HtmlFacade' => $vendorDir . '/laravelcollective/html/src/HtmlFacade.php',
'Collective\\Html\\HtmlServiceProvider' => $vendorDir . '/laravelcollective/html/src/HtmlServiceProvider.php',
之后
'ClassPreloader\\Parser\\NodeTraverser' => $vendorDir . '/classpreloader/classpreloader/src/Parser/NodeTraverser.php',
以便Laravel知道在需要时可以在哪里寻找这些类.
so that Laravel knows where to look for these classes when requested.
5)将此行作为最后一个元素添加到vendor/composer/autoload_files.php
5) Add this line as a last element to return array(...)
in vendor/composer/autoload_files.php
$vendorDir . '/laravelcollective/html/src/helpers.php',
6)将此行添加到vendor/composer/autoload_psr4.php
// 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'Collective\\Html\\' => array($vendorDir . '/laravelcollective/html/src'),
// 'ClassPreloader\\' => array($vendorDir . '/classpreloader/classpreloader/src'),
7)将提供程序添加到config/app.php的提供程序数组:
7) Add providers to providers array of config/app.php:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
8)将两个类别名添加到config/app.php的别名数组中:
8) Add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
参考文献:
http://laravelcollective.com/docs/5.1/html
这篇关于Laravel 5:在不使用Composer的情况下安装Form和HTML类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!