I just got this working using illuminate/console :
composer.json :
{ "require": { "illuminate/console": "^5.4", "illuminate/container": "^5.4", "illuminate/events": "^5.4" }, "autoload": { "psr-4": {"Yourvendor\\Yourproject\\": "src/"} } }
your-console-app (replacement for artisan ):
#!/usr/bin/env php <?php use Illuminate\Console\Application; use Illuminate\Container\Container; use Illuminate\Events\Dispatcher; use Yourvendor\Yourproject\Console\Commands\Yourcommand; if (file_exists($a = __DIR__.'/../../autoload.php')) { require_once $a; } else { require_once __DIR__.'/vendor/autoload.php'; } $container = new Container; $dispatcher = new Dispatcher; $version = "5.4";
src/Console/Commands/Yourcommand.php :
<?php namespace Yourvendor\Yourproject\Console\Commands; use Illuminate\Console\Command; class Yourcommand extends Command { protected $signature = 'yourcommand:test {test}'; protected $description = 'Yourcommand test'; public function handle() { $this->info('Hello world!'); } }
Run the console command using:
php your-console-app yourcommand:test
source share