在 try catch 非 Laravel 路由并呈现 Angular View 时,我遇到了 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');
});
最佳答案
App::missing() 已在 Laravel 5 中删除。您需要自己定义一个包罗万象的路由,只需确保将其放在 路由的末尾即可。 php:
Route::any('{catchall}', function() {
//some code
})->where('catchall', '.*');
关于php - Facade.php 第 216 行中的 FatalErrorException:调用未定义的方法 Illuminate\Foundation\Application::missing(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34742623/