Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Call a route in Laravel. Doens't quite work properly IIRC
use Illuminate\Console\Command;
use Illuminate\Routing\Router;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class CallRoute extends Command {
protected $name = 'route:call';
protected $description = 'Call route from CLI';
public function __construct()
public function fire()
parse_str($this->option('query'), $params); // by ref
$request = Request::create(
protected function getOptions()
return [
['uri', null, InputOption::VALUE_REQUIRED, 'The path of the route to be called', null],
['method', null, InputOption::VALUE_OPTIONAL, 'HTTP method (eg GET, POST)', 'GET'],
['query', null, InputOption::VALUE_OPTIONAL, 'Urlencoded GET params. Uses parse_str()', null],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment