【问题标题】:FatalErrorException in Facade.php line 216: Call to undefined method Illuminate\Foundation\Application::missing()Facade.php 第 216 行中的 FatalErrorException:调用未定义的方法 Illuminate\Foundation\Application::missing()
【发布时间】: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


    【解决方案1】:

    App::missing() 已在 Laravel 5 中删除。您需要自己定义一条包罗万象的路由,只需确保将其放在 路由的末尾即可。 php:

    Route::any('{catchall}', function() {
      //some code
    })->where('catchall', '.*');
    

    【讨论】:

    • 感谢它运行良好......甚至我在 laracast 频道上找到了解决方案。感谢您的评论.. laracasts.com/discuss/channels/general-discussion/…
    • 遇到了同样的问题,但实现了这个并且现在工作正常。谢谢@jedrzej.kurylo
    • 是的!你摇滚人!你摇滚!就是这样!
    猜你喜欢
    • 2015-09-23
    • 2014-04-17
    • 2018-06-25
    • 1970-01-01
    • 2019-09-28
    • 1970-01-01
    • 2016-04-21
    • 2017-08-24
    • 2023-04-01
    相关资源
    最近更新 更多