Php 如何修复反射异常类验证程序不存在错误
我最近正在编写一些代码,我得到了一个错误:第20行不存在反射异常类验证器 这是最后一批出现错误的代码,是桌面服务提供商:Php 如何修复反射异常类验证程序不存在错误,php,class,laravel,service-provider,laravel-validation,Php,Class,Laravel,Service Provider,Laravel Validation,我最近正在编写一些代码,我得到了一个错误:第20行不存在反射异常类验证器 这是最后一批出现错误的代码,是桌面服务提供商: /** * Register bindings * * @return void */ public function register() { $this->repositories(); $this->app->bind('\Desk\Forms\MessageForm', function($app) { $
/**
* 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();
}
服务供应商:
/**
* 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',
这似乎是您的自定义提供程序的代码。您可能应该将其添加到
app/config/app.php
文件的providers
部分的末尾,并最终添加到'illumb\Validation\ValidationServiceProvider'
之后,因为这里创建了$validator
正如我所说的,转到app/config/app.php
文件并找到以开头的部分
'providers'=>数组(
现在编辑提供商列表,将提供商放在提供商列表的末尾:
'providers' => array(
// here all list of all default providers
// here your custom provider
),
编辑
然后,您应该尝试更改:
$validator = $app->make('validator')->make([], []);
进入
很抱歉,我不确定您的意思。请编辑您的问题,将出现错误的服务提供商的开头包括在内;例如,它应该以类似
use-illumb\Support\ServiceProvider;class-MyServiceProvider在register()之前扩展ServiceProvider{…
的开头
函数。我已经更新了验证程序代码和提供程序,但仍然收到错误建议。@will.I.am是的,我看到了,但我不知道如何解决它,抱歉