找不到控制器方法.拉拉维尔 5.2 中的错误


Controller method not found. error in laravel 5.2

我的控制器文件看起来像这样

<?php
namespace App'Http'Controllers;
use App'Artist;
use App'Song;
use App'Album;
class WebsiteController extends Controller
{

    public function getIndex(){
        return redirect('/');
    }
    public function getHome(){
        $featuredArtist='';
        $featuredAlbum='';
        $featuredSong='';
        return view('website.welcome')->with(array('featuredArtist'=>$featuredArtist,'featuredSong'=>$featuredSong,'featuredAlbum'=>$featuredAlbum));
    }

    public function get_listartist(){
    $artistList = Artist::select('id','artist_name', 'artist_title','artist_image')->get();
    //dd($artistList);
    return view('website.listartist')->with(array('artistList'=>$artistList));
    //skljhkhkl
}
    public function getDonate(){
        return view('website.donate');
    }
    public function getContact(){
        return view('website.contact');
    }
}

而我的路线.php看起来像这样

<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'WebsiteController@getHome');
Route::controller('site', 'WebsiteController');

大多数链接都在工作,而不是

www.domain.com/site/listartist

我收到错误,因为

编译中的 NotFoundHttpException .php第 9361 行:控制器方法不是 发现。。

任何想法我检查了一切,看起来都很好

网址网站

谢谢

尝试snake-case方法的名称。我不知道为什么,但camel-case不适用于由两个词组成的方法。

public function get_some_name() {};  // www.example.com/anything/some-name
public function get_somename() {};  // www.example.com/anything/somename
//it doesn't seem to work with camel-case e.x  getSomename(); www.example.com/anything/somename
public function get_version() {}; //It will also work with camel-case

希望对您有所帮助。

即使这是旧的,它仍然可以帮助新访客。我得到了同样的错误,发现这是我在 web 中给出的控制器路径.php错误。

前任:而不是:路由::get('/', 'WebsiteController@getHome');

给路由::get('/', 'admin''WebsiteController@getHome');