luceos OK so what I have is (I removed imports and unrelated code) :
extend.php
return [
function (Application $app) {
$app->register(Providers\ConsoleProvider::class);
$events = $app['events'];
$events->subscribe(Listeners\RegisterConsoleCommand::class);
}
];
ConsoleProvider.php
class ConsoleProvider extends AbstractServiceProvider
{
public function register()
{
if (!defined('ARTISAN_BINARY')) {
define('ARTISAN_BINARY', 'flarum');
}
// Force registering the Schedule as singleton.
$this->app->register(Console::class); // FoF\Console\Providers\ConsoleProvider
$this->app->resolving(Schedule::class, function (Schedule $schedule) {
$schedule->command('post_scheduled_posts')
->everyMinute()
->withoutOverlapping();
});
}
}
RegisterConsoleCommand.php
class RegisterConsoleCommand
{
public function subscribe(Dispatcher $events)
{
$events->listen(Configuring::class, [$this, 'add']);
}
public function add(Configuring $event)
{
if ($event->app->bound(Schedule::class)) {
$event->addCommand(PostScheduledPosts::class);
}
}
}