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

laravelPHP

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

Best Answer

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');
Related Topic