搜索
首页后端开发php教程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模块调用时出错

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
11个最佳PHP URL缩短脚本(免费和高级)11个最佳PHP URL缩短脚本(免费和高级)Mar 03, 2025 am 10:49 AM

长URL(通常用关键字和跟踪参数都混乱)可以阻止访问者。 URL缩短脚本提供了解决方案,创建了简洁的链接,非常适合社交媒体和其他平台。 这些脚本对于单个网站很有价值

Instagram API简介Instagram API简介Mar 02, 2025 am 09:32 AM

在Facebook在2012年通过Facebook备受瞩目的收购之后,Instagram采用了两套API供第三方使用。这些是Instagram Graph API和Instagram Basic Display API。作为开发人员建立一个需要信息的应用程序

在Laravel中使用Flash会话数据在Laravel中使用Flash会话数据Mar 12, 2025 pm 05:08 PM

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

构建具有Laravel后端的React应用程序:第2部分,React构建具有Laravel后端的React应用程序:第2部分,ReactMar 04, 2025 am 09:33 AM

这是有关用Laravel后端构建React应用程序的系列的第二个也是最后一部分。在该系列的第一部分中,我们使用Laravel为基本的产品上市应用程序创建了一个RESTFUL API。在本教程中,我们将成为开发人员

简化的HTTP响应在Laravel测试中模拟了简化的HTTP响应在Laravel测试中模拟了Mar 12, 2025 pm 05:09 PM

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

php中的卷曲:如何在REST API中使用PHP卷曲扩展php中的卷曲:如何在REST API中使用PHP卷曲扩展Mar 14, 2025 am 11:42 AM

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

在Codecanyon上的12个最佳PHP聊天脚本在Codecanyon上的12个最佳PHP聊天脚本Mar 13, 2025 pm 12:08 PM

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

宣布 2025 年 PHP 形势调查宣布 2025 年 PHP 形势调查Mar 03, 2025 pm 04:20 PM

2025年的PHP景观调查调查了当前的PHP发展趋势。 它探讨了框架用法,部署方法和挑战,旨在为开发人员和企业提供见解。 该调查预计现代PHP Versio的增长

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具