Laravel 5: Installing Form and HTML classes without composer

跟風遠走 提交于 2019-12-10 21:18:49

问题


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) I want to see what it does by doing it manually myself at least once.

2) There is no composer on my hosting.

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.


回答1:


Installing laracollective/html:

1) Download zip package from extension's git repository

2) Unpack contents and create this directory structure: laravelcollective/html/{contents of html-5.1 directory}

3) Copy this structure to the vendor folder in your Laravel installation.

4) In vendor/composer/autoload_classmap.php add these lines

'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',

after

    'ClassPreloader\\Parser\\NodeTraverser' => $vendorDir . '/classpreloader/classpreloader/src/Parser/NodeTraverser.php',

so that Laravel knows where to look for these classes when requested.

5) Add this line as a last element to return array(...) in vendor/composer/autoload_files.php

$vendorDir . '/laravelcollective/html/src/helpers.php',

6) Add this line to return array(...) in 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) Add providers to providers array of config/app.php:

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

],

8) Add two class aliases to the aliases array of config/app.php:

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

],

References:

http://laravelcollective.com/docs/5.1/html



来源:https://stackoverflow.com/questions/32666164/laravel-5-installing-form-and-html-classes-without-composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!