2014-09-25 59 views
1

我最近的一些代碼工作,我得到這個錯誤:反射異常類驗證程序不上線20如何解決反射異常類驗證不存在錯誤

存在這是最後一批代碼有錯誤,是前臺服務提供商:

/** 
* Register bindings 
* 
* @return void 
*/ 
public function register() 
{ 
    $this->repositories(); 

    $this->app->bind('\Desk\Forms\MessageForm', function($app) { 
     $validator = $app['validator']->make([], []); (line 20) 
     return new \Desk\Forms\MessageForm($validator); 
    }); 
} 

/** 
* Register Repositories 
*/ 
protected function repositories() 
{ 

    $this->app->bindShared('\Desk\Repositories\MessageRepository', function($app) { 
     $record = new \Desk\Records\MessageRecord; 
     return new \Desk\Repositories\MessageRepository($record); 
    }); 
} 

服務提供商:

/** 
* Register bindings 
* 
* @return void 
*/ 
public function register() 
{ 
    $this->registerSupport(); 
} 

控制器:

protected $messageForm; 

public function __construct(MessageForm $messageForm, MessageRepository $messageRepository, 
    MessageRecord $messageRecord) 
{ 
    $this->messageForm = $messageForm; 
    $this->messageRepository = $messageRepository; 
    $this->messageRecord = $messageRecord; 
} 

/** 
* Display a listing of the resource. 
* GET /messages 
* 
* @return Response 
*/ 
public function index() 
{ 
    return View::make('message.create'); 
} 

的app.config

'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider', 
    'Illuminate\Auth\AuthServiceProvider', 
    'Illuminate\Cache\CacheServiceProvider', 
    'Illuminate\Session\CommandsServiceProvider', 
    'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 
    'Illuminate\Routing\ControllerServiceProvider', 
    'Illuminate\Cookie\CookieServiceProvider', 
    'Illuminate\Database\DatabaseServiceProvider', 
    'Illuminate\Encryption\EncryptionServiceProvider', 
    'Illuminate\Filesystem\FilesystemServiceProvider', 
    'Illuminate\Hashing\HashServiceProvider', 
    'Illuminate\Html\HtmlServiceProvider', 
    'Illuminate\Log\LogServiceProvider', 
    'Illuminate\Mail\MailServiceProvider', 
    'Illuminate\Database\MigrationServiceProvider', 
    'Illuminate\Pagination\PaginationServiceProvider', 
    'Illuminate\Queue\QueueServiceProvider', 
    'Illuminate\Redis\RedisServiceProvider', 
    'Illuminate\Remote\RemoteServiceProvider', 
    'Illuminate\Auth\Reminders\ReminderServiceProvider', 
    'Illuminate\Database\SeedServiceProvider', 
    'Illuminate\Session\SessionServiceProvider', 
    'Illuminate\Translation\TranslationServiceProvider', 
    'Illuminate\Validation\ValidationServiceProvider', 
    'Illuminate\View\ViewServiceProvider', 
    'Illuminate\Workbench\WorkbenchServiceProvider', 

    'Way\Generators\GeneratorsServiceProvider', 
    'Desk\ServiceProvider', 
    'Desk\Auth\AuthServiceProvider', 
    'Desk\Parts\PartServiceProvider', 
    'Desk\Desk\Repositories\RepoServiceProvider', 
    'Desk\Desk\Forms\FormServiceProvider', 
    'Desk\Desk\DeskServiceProvider', 

回答

1

似乎是爲您的自定義提供程序的代碼。您可能應該在providers部分的末尾添加app/config/app.php文件,並在'Illuminate\Validation\ValidationServiceProvider'之後定義它,因爲這裏是$validator已創建。

正如我所說的去app/config/app.php文件,並找到部分與

'providers' => array(

開始現在編輯你的供應商列表,把你的供應商在你的供應商列表的末尾:

'providers'  => array(

    // here all list of all default providers 
    // here your custom provider 
), 

編輯

然後您應該嘗試更改:

$validator = $app->make('validator')->make([], []); 

$validator = $app['validator']->make([], []); 
+0

我很抱歉,但我不知道你的意思。 – 2014-09-25 18:12:56

+0

請編輯您的問題,以包括髮生錯誤的服務提供商的開始;例如,它應該以'使用Illuminate \ Support \ ServiceProvider;類MyServiceProvider在'register()'函數之前擴展了ServiceProvider {...'。 – damiani 2014-09-25 18:32:10

+0

@ will.i.am我再次編輯我的答案 – 2014-09-25 18:43:59