/** * Get the Artisan console instance. * * @return Illuminate\Console\Application */ protected function getArtisan() { if (!is_null($this->artisan)) { return $this->artisan; } return $this->artisan = ConsoleApplication::start($this->app); }
/** * Get the Artisan console instance. * * @return \Illuminate\Console\Application */ protected function getArtisan() { if (!is_null($this->artisan)) { return $this->artisan; } $this->app->loadDeferredProviders(); return $this->artisan = ConsoleApplication::start($this->app); }
public function run() { if (!$this->checkUser()) { echo '<p>' . Lang::get('web-artisan::webartisan.terminal.needlogin') . '</p>'; return; } $parts = explode(" ", Input::get('cmd')); if (count($parts) < 2) { echo '<p>' . Lang::get('web-artisan::webartisan.terminal.invalidcmd') . '</p>'; return; } //first is "artisan" so remove it unset($parts[0]); //second is the command $cmd = $parts[1]; unset($parts[1]); $app = app(); $app->loadDeferredProviders(); $artisan = ConsoleApplication::start($app); $command = $artisan->find($cmd); $def = $command->getDefinition(); $arguments = $def->getArguments(); $fix = array(); foreach ($arguments as $argument) { $fix[] = $argument->getName(); } $arguments = $fix; $params = array(); //the rest should be the parameter list $i = 0; //The counter for our argument list foreach ($parts as $param) { // foo=bar, we don't need to work more if (strpos($param, "=") !== false) { $param = explode("=", $param, 2); $params[$param[0]] = $param[1]; } else { //Do we have an argument or an option? if (substr($param, 0, 1) == "-") { $params[$param] = true; //Option, simply set it to true } else { //Argument, we need a bit work $params[$arguments[$i]] = $param; ++$i; } } } $params['command'] = $cmd; $input = new ArrayInput($params); $command->run($input, new Output()); }
/** * Create and boot a new Console application. * * @param \Illuminate\Foundation\Application $app * @return \Illuminate\Console\Application * @static */ public static function start($app) { return \Illuminate\Console\Application::start($app); }