【发布时间】:2016-04-17 00:09:45
【问题描述】:
在尝试捕获我的非 Laravel 路由并呈现 Angular 视图时,我遇到了混合 Laravel 和 Angular 路由的问题..
在我的 app\http\route.php 中添加缺少的方法时出现以下错误:
Facade.php 第 216 行中的 FatalErrorException:调用未定义的方法 Illuminate\Foundation\Application::missing()
我知道这适用于 laravel 5 或更低版本,但不适用于我目前使用的 laravel 5.2,那么如何在 laravel 5.2 中编码?有什么解决办法吗?
route.php 看起来像:
<?php // app/routes.php
// HOME PAGE ===================================
// I am not using Laravel Blade
// I will return a PHP file that will hold all of our Angular content
Route::get('/', function() {
View::make('index'); // will return app/views/index.php
});
// API ROUTES ==================================
Route::group(['prefix' => 'api'], function() {
// Angular will handle both of those forms
// this ensures that a user can't access api/create or api/edit when there's nothing there
Route::resource('comments', 'CommentController',
['only' => ['index', 'store', 'destroy']]);
});
// CATCH ALL ROUTE =============================
// all routes that are not home or api will be redirected to the frontend
// this allows angular to route them
App::missing(function($exception) {
return View::make('index');
});
【问题讨论】:
标签: php angularjs laravel laravel-5 laravel-5.2