laravel 5.2 form模块调用时出错
错误代码
Call to undefined method Illuminate\Foundation\Application::bindShared()
原因
The Form and HTML helpers have been deprecated in Laravel 5.0; form模块依赖于laravel 5.0框架,所以在默认的5.2框架里调用还是会有问题,现时5.2还没有作出修复,所以需要重新安装。
解决
1.在composer.json文件的require里添加一行”laravelcollective/html”: “~5.0″完成版
"require": { "php": ">=5.5.9", "laravel/framework": "5.2.*", "illuminate/html": "^5.0", "barryvdh/laravel-ide-helper": "v2.1.2", "laravelcollective/html": "~5.0" },
composer.json位置在laravel目录根层
2.然后运行命令
composer update主要是通过composer来重新管理laravel框架的文件
以下是更新过程
composer update> php artisan clear-compiledLoading composer repositories with package informationUpdating dependencies (including require-dev) - Removing symfony/yaml (v3.0.1) - Installing symfony/yaml (v3.0.2) Downloading: 100% - Removing phpspec/prophecy (v1.5.0) - Installing phpspec/prophecy (v1.6.0) Downloading: 100% - Removing phpunit/phpunit (4.8.21) - Installing phpunit/phpunit (4.8.23) Downloading: 100% - Removing symfony/css-selector (v3.0.1) - Installing symfony/css-selector (v3.0.2) Downloading: 100% - Removing symfony/dom-crawler (v3.0.1) - Installing symfony/dom-crawler (v3.0.2) Downloading: 100% - Removing paragonie/random_compat (1.1.6) - Installing paragonie/random_compat (v1.2.0) Downloading: 100% - Removing symfony/console (v3.0.1) - Installing symfony/console (v3.0.2) Downloading: 100% - Removing symfony/finder (v3.0.1) - Installing symfony/finder (v3.0.2) Downloading: 100% - Removing symfony/debug (v3.0.1) - Installing symfony/debug (v3.0.2) Downloading: 100% - Removing symfony/http-foundation (v3.0.1) - Installing symfony/http-foundation (v3.0.2) Downloading: 100% - Removing symfony/event-dispatcher (v3.0.1) - Installing symfony/event-dispatcher (v3.0.2) Downloading: 100% - Removing symfony/http-kernel (v3.0.1) - Installing symfony/http-kernel (v3.0.2) Downloading: 100% - Removing symfony/process (v3.0.1) - Installing symfony/process (v3.0.2) Downloading: 100% - Updating symfony/routing (v3.0.1 => v3.0.2) The package has modified files: M .gitignore M Annotation/Route.php M CHANGELOG.md M CompiledRoute.php M Exception/ExceptionInterface.php M Exception/InvalidParameterException.php M Exception/MethodNotAllowedException.php M Exception/MissingMandatoryParametersException.php M Exception/ResourceNotFoundException.php M Exception/RouteNotFoundException.php-10 more files modified, choose "v" to view the full list Discard changes [y,n,v,d,s,?]? y Checking out 4686baa55a835e1c1ede9b86ba02415c8c8d6166 - Removing symfony/translation (v3.0.1) - Installing symfony/translation (v3.0.2) Downloading: 100% - Removing symfony/var-dumper (v3.0.1) - Installing symfony/var-dumper (v3.0.2) Downloading: 100% - Removing laravel/framework (v5.2.12) - Installing laravel/framework (v5.2.16) Downloading: 100% - Installing laravelcollective/html (v5.2.4) Downloading: 100%Writing lock fileGenerating autoload files> php artisan optimizeGenerating optimized class loader
3.更新成功后,修改config/app.php文件增加配置:
#增加providers数组项 'providers' => [ // ... Collective\Html\HtmlServiceProvider::class, // ... ], #增加alias数组项 'aliases' => [ // ... 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, // ... ],
以下是完成版
'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, Collective\Html\HtmlServiceProvider::class, #注意,就是这里 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', // Laravel IDE helper /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, ], /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, 'Form' => Collective\Html\FormFacade::class,#注意,就是这里 'Html' => Collective\Html\HtmlFacade::class,#注意,就是这里 ],
参考文件:
https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0
https://laravelcollective.com/docs/5.1/html#installation
http://stackoverflow.com/questions/34414389/fatalerrorexception-in-htmlserviceprovider-php-line-36-laravel
本文由 PeterYuan 创作,采用 署名-非商业性使用 2.5 中国大陆 进行许可。 转载、引用前需联系作者,并署名作者且注明文章出处。神一样的少年 » laravel 5.2 form模块调用时出错

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

PHP中有四種主要錯誤類型:1.Notice:最輕微,不會中斷程序,如訪問未定義變量;2.Warning:比Notice嚴重,不會終止程序,如包含不存在文件;3.FatalError:最嚴重,會終止程序,如調用不存在函數;4.ParseError:語法錯誤,會阻止程序執行,如忘記添加結束標籤。

在PHP中,應使用password_hash和password_verify函數實現安全的密碼哈希處理,不應使用MD5或SHA1。1)password_hash生成包含鹽值的哈希,增強安全性。 2)password_verify驗證密碼,通過比較哈希值確保安全。 3)MD5和SHA1易受攻擊且缺乏鹽值,不適合現代密碼安全。

PHP和Python各有優勢,選擇依據項目需求。 1.PHP適合web開發,尤其快速開發和維護網站。 2.Python適用於數據科學、機器學習和人工智能,語法簡潔,適合初學者。

PHP在電子商務、內容管理系統和API開發中廣泛應用。 1)電子商務:用於購物車功能和支付處理。 2)內容管理系統:用於動態內容生成和用戶管理。 3)API開發:用於RESTfulAPI開發和API安全性。通過性能優化和最佳實踐,PHP應用的效率和可維護性得以提升。

HTTP請求方法包括GET、POST、PUT和DELETE,分別用於獲取、提交、更新和刪除資源。 1.GET方法用於獲取資源,適用於讀取操作。 2.POST方法用於提交數據,常用於創建新資源。 3.PUT方法用於更新資源,適用於完整更新。 4.DELETE方法用於刪除資源,適用於刪除操作。

PHP是一種廣泛應用於服務器端的腳本語言,特別適合web開發。 1.PHP可以嵌入HTML,處理HTTP請求和響應,支持多種數據庫。 2.PHP用於生成動態網頁內容,處理表單數據,訪問數據庫等,具有強大的社區支持和開源資源。 3.PHP是解釋型語言,執行過程包括詞法分析、語法分析、編譯和執行。 4.PHP可以與MySQL結合用於用戶註冊系統等高級應用。 5.調試PHP時,可使用error_reporting()和var_dump()等函數。 6.優化PHP代碼可通過緩存機制、優化數據庫查詢和使用內置函數。 7

在PHPOOP中,self::引用當前類,parent::引用父類,static::用於晚靜態綁定。 1.self::用於靜態方法和常量調用,但不支持晚靜態綁定。 2.parent::用於子類調用父類方法,無法訪問私有方法。 3.static::支持晚靜態綁定,適用於繼承和多態,但可能影響代碼可讀性。

PHP通過$\_FILES變量處理文件上傳,確保安全性的方法包括:1.檢查上傳錯誤,2.驗證文件類型和大小,3.防止文件覆蓋,4.移動文件到永久存儲位置。
