我刚开始玩 laravel。首先,这是我遇到的最好的框架。现在这是我的问题。我试图从路由指向 -> Controller -> View
//This is my Controller file
public function index()
{
return View::make('pages', array('name' => 'Taylor'));
}
// This is my Routes File
Route::get('/', 'pagesController@index');
View file => pages.blade.php
这是我得到的错误。
FatalErrorException in pagesController.php line 19:
Class 'App\Http\Controllers\View' not found
最佳答案
从错误看来,问题在于 View
在当前命名空间中找不到类。
试试这个方法:
//use the View class from the global namespace
return \View::make('pages', array('name' => 'Taylor'));
或导入
View
Controller 脚本开头的类:use View;
关于php - 如何在 Laravel 中以正确的方式设置路由、 Controller 和 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31493794/