添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

UnexpectedValueException in Route.php line 639: Invalid route action: [App\Http\Controllers\PortfolioController]

Ask Question

Why am I getting this error. I created a PortfolioController. Then I made a route using this

Route::get('portfolio','PortfolioController');  

So in my controller page I made this.

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!';

I get this error when typing in localhost/portfolio/paintings

From the look of your code, it looks like you're trying to setup an implicit controller route. You're close, but your route definition is a little off. You need to use controller instead of get:

Route::controller('portfolio','PortfolioController');
                Actually I am now getting : NotFoundHttpException in Controller.php line 269: Controller method not found.
– Tbaustin
                Oct 17, 2015 at 21:28
                I found the fix to that issue. I just had to install laravelcollective/html through composer, by  going to cmd prompt and typing in 'composer require laravelcollective/html'
– Tbaustin
                Oct 17, 2015 at 21:36

https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0

The following features are deprecated in 5.2 and will be removed in the 5.3 release in June 2016:

  • Implicit controller routes using Route::controller have been deprecated. Please use explicit route registration in your routes file. This will likely be extracted into a package.
  • You must declare each endpoint now.

    Please add some explanation to your answer such that others can learn from it. To met, this looks like a duplicate of the answer given by Ryuujo – Nico Haase Oct 19, 2020 at 6:00

    You have to consume a function of the controller instead of using the whole controller class for one request. so laravel doesn't know which of your function to use.

    Try using PortfolioController@index. or Route::resource('yourroute','PortfolioController');

    Because the function of that Controller is just getPaintings, so I think to use PortofolioController@getPaintings – Ryuujo Jan 9, 2019 at 7:16