为什么会出现这种错误。我创建了一个PortfolioController。然后,我用这个做了一个路线
Route::get('portfolio','PortfolioController');
所以在我的控制页面我做了这个。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class PortfolioController extends Controller
{
//This only gets exectued when we request /portfolio/Paintings using GET
public function getPaintings()
{
return 'This RESTful controller is working!';
}
}
在本地主机/组合/画打字的时候,我得到这个错误
从你的代码看,它看起来像你试图建立一个implicit controller route。你靠近,但你的路由定义是有点过。您需要改用controller
的get
:
Route::controller('portfolio','PortfolioController');
https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0
以下功能已被弃用在5.2,将在2016年6月的5.3版本中删除:
- 使用
Route::controller
隐式控制器的路线已被弃用。请你的路由文件中使用显式路由注册。这可能会被提取到一个包。
你必须现在宣布每个端点。
我有一个类似的错误时有web.php的文件中的一个错误。
正确的路线会喜欢这个Route::get('portfolio','YourController@yourMethod');
你必须消耗控制器的功能,而不是使用整个控制器类的一个请求。所以laravel不知道用哪个你的函数。
尝试使用PortfolioController@index
。或Route::resource('yourroute','PortfolioController');
试试这个:路线::资源( '/组合', 'PortfolioController');希望这会工作
在使用此航线的代码:
Route::resource('portfolio','YourController@yourMethod');
你需要解释你的路由功能。例:
Route::methods('your-uri','YourController@YourFunction');
所以你应该这样做:
Route::get('portfolio','PortfolioController@getPaintings');
希望能帮助到你