Laravel 5:RouteCollection.php第219行

时间:2017-01-08 04:08:52

标签: php laravel-5

当我尝试访问页面时,我得到MethodNotAllowedHttpException。这曾经起作用,但无法弄清楚我做了什么来打破它。

routes.php文件

Route::post('api', ['middleware' => 'api', 'uses' => 'DeviceController@api']);

DeviceController.php

public function api()
{
    return view('api');
}

api.blade.php(我已经修改了api.blade.php来排除它作为问题的根源。)

<?php echo 'test'; ?>

应用程序/ HTTP / kernal.php

    protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
    ],

    'api' => [
        'throttle:60,1',
        'auth:api',
    ],
];

配置/ auth.php

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'devices',
    ],
],
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],

    'devices' => [
        'driver' => 'eloquent',
        'model' => App\Device::class,
    ],
],

应用程序/提供者/ RouteServiceProvider.php

public function map(Router $router)
{
    $router->group([
        'namespace' => $this->namespace,
    ], function ($router) {
        require app_path('Http/routes.php');
    });
}

我正在使用邮递员来模拟POST请求。

1 个答案:

答案 0 :(得分:0)

我弄明白了这个问题。在尝试使用http时,我正在强制与.htaccess文件建立安全连接。