Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

laravel

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.

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

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

like image 828
Tbaustin Avatar asked Oct 17 '15 03:10

Tbaustin


4 Answers

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');
like image 160
patricus Avatar answered Nov 20 '22 05:11

patricus


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.

like image 32
Tiago Gouvêa Avatar answered Nov 20 '22 04:11

Tiago Gouvêa


try this

Route::get('portfolio','PortfolioController@getPaintings')

like image 2
Muhammad Kamran Avatar answered Nov 20 '22 03:11

Muhammad Kamran


I got a similar error when there was a mistake in he file of web.php.

A correct route would like this Route::get('portfolio','YourController@yourMethod');

like image 1
Alan-Wen Avatar answered Nov 20 '22 04:11

Alan-Wen