根据文档将 Laravel 升级到 v7 后,我运行了 composer update。然后我得到这个:
脚本@php artisan package:discover --ansi 处理返回错误代码 255 的 post-autoload-dump 事件
这是我的 composer.json 文件:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.5",
"kitetail/zttp": "^0.6.0",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravel/telescope": "^2.1",
"laravelcollective/html": "^6.0",
"livewire/livewire": "^0.7.4",
"spatie/laravel-html": "^2.24",
"spatie/laravel-permission": "^3.0.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"laravel/ui": "^2.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": …Run Code Online (Sandbox Code Playgroud) 正如在基本的 Laracasts.com 教程(从头开始的 Laracast 5.7)中一样,我尝试使用以下方法public function show(prototypes $prototypes)参数来构造视图。但是我的视图创建正确但$prototypes为空。
该路线运行良好( /prototypes/1/edit),并且我确保prototype存在 id 为 1 的对象。我找到了一些较旧的解决方案,其中规定使用类似(integer $id)参数的内容,但这会导致更多代码。它应该像这样工作:
控制器:
public function edit(prototypes $prototypes)
{
//
return view('prototypes.edit', compact('prototypes'));
}
Run Code Online (Sandbox Code Playgroud)
根据Laracast From Scratch 的说法,这应该可行。
你知道我该如何解决这个问题吗?
该prototypes.edit方法知道如何使用正确的参数,这背后的机制是什么?