php - Facade.php 第 216 行中的 FatalErrorException:调用未定义的方法 Illuminate\Foundation\Application::missing()

标签 php angularjs laravel laravel-5


在 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/

相关文章:

PHP 解析错误 : syntax error, 意外 '?' - laravel

php解析json数据

php - 如何从不同日期的数据中获取当月的数据?

php - Google 语音 API - php 不返回任何内容

javascript - Ajax 表单提交没有结果

angularjs - Angular Promise - 对成功和错误都做一些事情

javascript - 如何在 AngularJS 中使用 $timeout 运行带参数的函数?

templates - 推荐可扩展的 AngularJS 项目结构?

javascript - 尝试将一些 JavaScript 嵌入到 Laravel View 中的 foreach 循环中

javascript - Vue.js 2.0 Laravel 5.4 将对象传递给应用程序并跨组件全局使用它