2016-03-01 22 views
1

缺少參數2我在laravel 5應用程序中工作,我試圖調試在後臺運行的數據庫查詢。對於App Providers AppServiceProvider :: App Providers {closure}()

所以,我想的方式,很多人在社區嘗試:

https://laravel.com/docs/5.1/database#listening-for-query-events

但讓我吃驚,我又回到由laravel拋出一個奇怪的例外,他說:

缺少參數2 for App \ Providers \ AppServiceProvider :: App \ Providers {closure}()

[2016-03-01 07:12:18] local.ERROR: exception 'ErrorException' with message 'Missing argument 2 for App\Providers\AppServiceProvider::App\Providers\{closure}()' in /home/vagrant/Code/tenant-application/app/Providers/AppServiceProvider.php:19 
Stack trace: 
#0 /home/vagrant/Code/tenant-application/app/Providers/AppServiceProvider.php(19): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Missing argumen...', '/home/vagrant/C...', 19, Array) 
#1 [internal function]: App\Providers\AppServiceProvider->App\Providers\{closure}(Object(Illuminate\Database\Events\QueryExecuted)) 
#2 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(221): call_user_func_array(Object(Closure), Array) 
#3 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Connection.php(750): Illuminate\Events\Dispatcher->fire(Object(Illuminate\Database\Events\QueryExecuted)) 
#4 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Connection.php(641): Illuminate\Database\Connection->logQuery('select * from `...', Array, 1.26) 
#5 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Connection.php(342): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure)) 
#6 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1461): Illuminate\Database\Connection->select('select * from `...', Array, true) 
#7 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1447): Illuminate\Database\Query\Builder->runSelect() 
#8 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(569): Illuminate\Database\Query\Builder->get(Array) 
#9 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(303): Illuminate\Database\Eloquent\Builder->getModels(Array) 
#10 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(273): Illuminate\Database\Eloquent\Builder->get(Array) 
#11 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php(100): Illuminate\Database\Eloquent\Builder->first() 
#12 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php(353): Illuminate\Auth\EloquentUserProvider->retrieveByCredentials(Array) 
#13 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php(256): Illuminate\Auth\SessionGuard->attempt(Array, false, false) 
#14 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php(239): Illuminate\Auth\SessionGuard->validate(Array) 
#15 [internal function]: Illuminate\Auth\SessionGuard->once(Array) 
#16 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php(282): call_user_func_array(Array, Array) 
#17 /home/vagrant/Code/tenant-application/vendor/tymon/jwt-auth/src/Providers/Auth/IlluminateAuthAdapter.php(39): Illuminate\Auth\AuthManager->__call('once', Array) 
#18 /home/vagrant/Code/tenant-application/vendor/tymon/jwt-auth/src/Providers/Auth/IlluminateAuthAdapter.php(39): Illuminate\Auth\AuthManager->once(Array) 
#19 /home/vagrant/Code/tenant-application/vendor/tymon/jwt-auth/src/JWTAuth.php(108): Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter->byCredentials(Array) 
#20 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Tymon\JWTAuth\JWTAuth->attempt(Array, Array) 
#21 /home/vagrant/Code/tenant-application/vendor/archiveonline/tenant-package/src/Controllers/Auth/AuthController.php(43): Illuminate\Support\Facades\Facade::__callStatic('attempt', Array) 
#22 /home/vagrant/Code/tenant-application/vendor/archiveonline/tenant-package/src/Controllers/Auth/AuthController.php(43): Tymon\JWTAuth\Facades\JWTAuth::attempt(Array, Array) 
#23 [internal function]: Uppdragshuset\AO\Tenant\Controllers\Auth\AuthController->authenticate() 
#24 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(78): call_user_func_array(Array, Array) 
#25 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('authenticate', Array) 
#26 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(Uppdragshuset\AO\Tenant\Controllers\Auth\AuthController), Object(Illuminate\Routing\Route), 'authenticate') 
#27 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#28 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#29 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#30 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#31 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then(Object(Closure)) 
#32 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(Uppdragshuset\AO\Tenant\Controllers\Auth\AuthController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'authenticate') 
#33 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Uppdragshuset\\A...', 'authenticate') 
#34 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Route.php(140): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request)) 
#35 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Router.php(724): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request)) 
#36 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#37 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#38 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#39 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#40 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure)) 
#41 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) 
#42 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) 
#43 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) 
#44 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) 
#45 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#46 /home/vagrant/Code/tenant-application/vendor/archiveonline/tenant-package/src/Middleware/Cors.php(25): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#47 [internal function]: Uppdragshuset\AO\Tenant\Middleware\Cors->handle(Object(Illuminate\Http\Request), Object(Closure)) 
#48 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) 
#49 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) 
#50 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#51 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#52 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) 
#53 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) 
#54 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) 
#55 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#56 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
#57 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) 
#58 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure)) 
#59 /home/vagrant/Code/tenant-application/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) 
#60 /home/vagrant/Code/tenant-application/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) 
#61 {main} 

這就是追蹤,但我無法弄清楚我在這裏做錯了什麼。

AppServiceProvider.php

<?php 

namespace App\Providers; 

use Illuminate\Support\ServiceProvider; 

use DB; 
use Log; 

class AppServiceProvider extends ServiceProvider 
{ 
    /** 
    * Bootstrap any application services. 
    * 
    * @return void 
    */ 
    public function boot() 
    { 
     DB::listen(function($sql, $bindings, $time) { 
      Log::info($time . "\r\n" . $sql); 
     }); 
    } 

    /** 
    * Register any application services. 
    * 
    * @return void 
    */ 
    public function register() 
    { 
     // 
    } 
} 
+0

粘貼代碼從你AppServiceProvider – markdwhite

+0

添加它。任何想法? – Rohan

+0

你在5.1嗎?這表明你可能在5.2 http://stackoverflow.com/questions/27753868/how-to-get-the-query-executed-in-laravel-5-dbgetquerylog-returning-empty-arr/34638344#34638344,因此https://laravel.com/docs/5.2/database#listening-for-query-events – markdwhite

回答

相關問題