控制器无法make模板
laravel版本是5.2
1 我在routes.php里边写
Route::get('/test', function () {
return View::make('articles.create');
});
就可以访问,
2 我在自定义的根目录/app/http/contorllers/下新建的控制器,无法读取模板文件
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class WelcomeController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function index(){
return View::make('articles.create');
}
}
这样就报错了
3 错误提示:
Whoops, looks like something went wrong.
1/1
FatalErrorException in WelcomeController.php line 16:
Class 'App\Http\Controllers\View' not found
in WelcomeController.php line 16
1 我在routes.php里边写
Route::get('/test', function () {
return View::make('articles.create');
});
就可以访问,
2 我在自定义的根目录/app/http/contorllers/下新建的控制器,无法读取模板文件
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class WelcomeController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function index(){
return View::make('articles.create');
}
}
这样就报错了
3 错误提示:
Whoops, looks like something went wrong.
1/1
FatalErrorException in WelcomeController.php line 16:
Class 'App\Http\Controllers\View' not found
in WelcomeController.php line 16
1 个回复
心中的日月
赞同来自:
1 routes.php 文件,展示视图时需要
return View::make('articles.create');
2 控制器里边 直接:
return View('articles.create');
就可以了