Closed
Description
This is what I have:
Adding the command to Artisan via resolve():
Artisan::resolve('App\Commands\Whitelist');
The Command:
<?php namespace App\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use App\Repositories\DataRepositoryInterface;
class Whitelist extends Command {
protected $name = 'app:whitelist';
protected $dataRepository;
protected $description = 'Whitelist an IP address to the app.';
public function __construct(DataRepositoryInterface $dataRepository)
{
parent::__construct();
$this->dataRepository = $dataRepository;
}
public function fire()
{
echo $this->argument('ip');
}
protected function getArguments()
{
return array(
array('ip', InputArgument::REQUIRED, 'The IP address to be whitelisted.'),
);
}
}
Trying to use the command gives me this error:
[2013-12-07 22:34:54] development.ERROR: exception 'ReflectionException' with message 'Class App\Repositories\DataRepositoryInterface does not exist' in /application.dev/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:522
Stack trace:
#0 application.dev/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(522): ReflectionParameter->getClass()
#1 application.dev/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(505): Illuminate\Container\Container->getDependencies(Array)
#2 application.dev/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(416): Illuminate\Container\Container->build('App...', Array)
#3 application.dev/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(423): Illuminate\Container\Container->make('App...', Array)
#4 application.dev/app/vendor/laravel/framework/src/Illuminate/Container/Container.php(752): Illuminate\Foundation\Application->make('App...')
#5 application.dev/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(133): Illuminate\Container\Container->offsetGet('App...')
#6 application.dev/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(208): Illuminate\Console\Application->resolve('App...')
#7 application.dev/app/app/start/artisan.php(14): Illuminate\Support\Facades\Facade::__callStatic('resolve', Array)
#8 application.dev/app/app/start/artisan.php(14): Illuminate\Support\Facades\Artisan::resolve('App...')
#9 application.dev/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(62): require('/application.dev...')
#10 application.dev/app/vendor/laravel/framework/src/Illuminate/Console/Application.php(32): Illuminate\Console\Application->boot()
#11 application.dev/app/artisan(46): Illuminate\Console\Application::start(Object(Illuminate\Foundation\Application))
#12 {main} [] []
But I also have this controller where the same resolution works fine:
<? namespace App\Controllers;
use Controller;
use Redirect;
use App\Repositories\DataRepositoryInterface;
class FirewallController extends BaseController {
private $dataRepository;
public function __construct(DataRepositoryInterface $dataRepository)
{
$this->dataRepository = $dataRepository;
}
public function whitelist($ip)
{
return Redirect::to('/')->withMessages(
$this->
dataRepository->
firewall->
addToWhitelist($ip)->
getMessages()
);
}
}
Without the dependency command works fine.
Am I doing something wrong or it's a bug?
Metadata
Metadata
Assignees
Labels
No labels