2016-05-25 9 views
3

ちょっとルーメン5.2に更新し、jwt-authで問題が発生しました。私はすべての指示に従い、すべてのミドルウェアを含むapp.phpファイルを更新しました。私はまた、作曲家は照明/ルーティングと照明/認証が必要です。私はそのエラーのうちのいずれかの感覚を得ることができないようルーメン:jwt-authでメソッドハンドルが存在しません。ミドルウェアを実行しました

BadMethodCallException in Macroable.php line 81: Method handle does not exist. in Macroable.php line 81 at ResponseFactory->__call('handle', array(object(Request), object(Closure)))

: は、しかし、私はエラーを取得しますか?あなたの助けのための

<?php 

require_once __DIR__.'/../vendor/autoload.php'; 

try { 
    (new Dotenv\Dotenv(__DIR__.'/../'))->load(); 
} catch (Dotenv\Exception\InvalidPathException $e) { 
    // 
} 

/* 
|-------------------------------------------------------------------------- 
| Create The Application 
|-------------------------------------------------------------------------- 
| 
| Here we will load the environment and create the application instance 
| that serves as the central piece of this framework. We'll use this 
| application as an "IoC" container and router for this framework. 
| 
*/ 

//$app = new Laravel\Lumen\Application(
// realpath(__DIR__.'/../') 
//); 

// For nested route groups to work 
$app = new Fremail\NestedRouteGroups\Application(
    realpath(__DIR__.'/../') 
); 

$app->withFacades(); 

$app->configure('jwt'); 
$app->configure('auth'); 

class_alias(Tymon\JWTAuth\Facades\JWTAuth::class, 'JWTAuth'); 
class_alias(Tymon\JWTAuth\Facades\JWTFactory::class, 'JWTFactory'); 


$app->withEloquent(); 

/* 
|-------------------------------------------------------------------------- 
| Register Container Bindings 
|-------------------------------------------------------------------------- 
| 
| Now we will register a few bindings in the service container. We will 
| register the exception handler and the console kernel. You may add 
| your own bindings here if you like or you can make another file. 
| 
*/ 

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class, 
    App\Exceptions\Handler::class 
); 

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class, 
    App\Console\Kernel::class 
); 

$app->singleton(
    Illuminate\Cache\CacheManager::class, 
    function ($app) { 
     return $app->make('cache'); 
    } 
); 

$app->singleton(
    Illuminate\Auth\AuthManager::class, 
    function ($app) { 
     return $app->make('auth'); 
    } 
); 

$app->singleton(
    Illuminate\Contracts\Routing\ResponseFactory::class, 
    Illuminate\Routing\ResponseFactory::class 
); 


/* 
|-------------------------------------------------------------------------- 
| Register Middleware 
|-------------------------------------------------------------------------- 
| 
| Next, we will register the middleware with the application. These can 
| be global middleware that run before and after each request into a 
| route or middleware that'll be assigned to some specific routes. 
| 
*/ 

$app->middleware([ 
    Illuminate\Contracts\Routing\ResponseFactory::class, 
//  // Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 
//  // Illuminate\Session\Middleware\StartSession::class, 
//  // Illuminate\View\Middleware\ShareErrorsFromSession::class, 
// Laravel\Lumen\Http\Middleware\VerifyCsrfToken::class, 
]); 

// Middleware for authentication for the API 
$app->routeMiddleware([ 
    'auth'  => App\Http\Middleware\Authenticate::class, 
    'jwt.auth' => Tymon\JWTAuth\Middleware\GetUserFromToken::class, 
    'jwt.refresh' => Tymon\JWTAuth\Middleware\RefreshToken::class, 
]); 

/* 
|-------------------------------------------------------------------------- 
| Register Service Providers 
|-------------------------------------------------------------------------- 
| 
| Here we will register all of the application's service providers which 
| are used to bind services into the container. Service providers are 
| totally optional, so you are not required to uncomment this line. 
| 
*/ 

$app->register(App\Providers\GuardServiceProvider::class); 
$app->register(Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class); 

/* 
|-------------------------------------------------------------------------- 
| Load The Application Routes 
|-------------------------------------------------------------------------- 
| 
| Next we will include the routes file so that they can all be added to 
| the application. This will provide all of the URLs the application 
| can respond to, as well as the controllers that may handle them. 
| 
*/ 

$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { 
    require __DIR__.'/../app/Http/routes.php'; 
}); 

return $app; 

おかげで

+0

、その例外をスローしてメソッドを動的にクラスにコールを処理しようとしている...あなたはそれが内腔に同じです確認することができますか?あるクラスで何か 'handle()'が呼び出されているようですが、このメソッドはそのクラスに存在しません。 – camelCase

+0

ええ、私はそれが基本的にここでも起こっていると思います。何かがResponseFactoryで 'handle'を呼び出そうとしていますが、存在しません。 http://imgur.com/SIKYA52 –

+0

エラーの原因となっている問題のコードを表示できますか? – Feek

答えて

4

私の答えが遅刻する必要がありますが、将来のGooglerのために、ここで私はそれ(ルーメン5.3を解決する方法である:ここでは

は、参考のために私のブートストラップ/ app.phpです):

私は、ブートストラップ/ app.phpで認証ミドルウェアを設定しました:

$app->routeMiddleware([ 
    'auth' => App\Http\Middleware\Authenticate::class 
]); 
+0

私の一日を保存!本当にありがとう! – basagabi

+0

おそらく私の人生の一日を節約しました.. – Sisir

0

私はまた目に会いましたあなたと同じ過ちです。

しかし、ルーティングファイルを間違えました。 ルーティングファイルを書き込む:

$app->middleware(['auth'],function()use($app){ 
    $app->group(['prefix'=>'pur'],function()use($app){ 
     $app->get('list','[email protected]'); 
    }); 
}); 

これは間違っています。 ルーティングは、最初に定義されなければならない。

$app->group(['middleware' => ['auth']], function() use ($app) { 
$app->group(['prefix'=>'pur'],function()use($app){ 
    $app->get('list','[email protected]'); 
}); 

})。

私の誤った情報:Laravelで

enter image description here

関連する問題