Him*_*kar 2 php laravel angularjs laravel-5 laravel-5.2
我有一个混合使用Laravel和Angular路由的问题,同时尝试捕获我的非Laravel路由并呈现Angular视图.
我在app\http\route.php中添加了丢失的方法后出现以下错误:
Facade.php第216行中的FatalErrorException:调用未定义的方法Illuminate\Foundation\Application :: missing()
我知道这对laravel 5或者down版本可以正常工作,但是我目前没有使用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');
});
Run Code Online (Sandbox Code Playgroud)
应用::失踪()已在Laravel 5.被删除,您需要定义一个包罗万象的自己的路线,只要确保你把它放在你的最后routes.php文件:
Route::any('{catchall}', function() {
//some code
})->where('catchall', '.*');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2623 次 |
| 最近记录: |