getApplication()->setCatchExceptions(false); $config = new Configuration; $config->getPresenter()->addCasters( $this->getCasters() ); $shell = new Shell($config); $shell->addCommands($this->getCommands()); $shell->setIncludes($this->argument('include')); $shell->run(); } /** * Get artisan commands to pass through to PsySH. * * @return array */ protected function getCommands() { $commands = []; foreach ($this->getApplication()->all() as $name => $command) { if (in_array($name, $this->commandWhitelist)) { $commands[] = $command; } } return $commands; } /** * Get an array of Laravel tailored casters. * * @return array */ protected function getCasters() { return [ 'Illuminate\Foundation\Application' => 'Illuminate\Foundation\Console\IlluminateCaster::castApplication', 'Illuminate\Support\Collection' => 'Illuminate\Foundation\Console\IlluminateCaster::castCollection', 'Illuminate\Database\Eloquent\Model' => 'Illuminate\Foundation\Console\IlluminateCaster::castModel', ]; } /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [ ['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'], ]; } }