#!/usr/bin/env php
<?php
/**
 * THIS CRON FILE IS A BACKUP METHOD IF YOUR SERVER DOES NOT HAVE PROC_OPEN ENABLED
 * YOU SHOULD TRY USING THE DEFAULT INSTRUCTIONS OF USING ARTISAN SCHEDULE:RUN
 */
define('LARAVEL_START', microtime(true));

use App\Console\Cron;
use App\Console\Kernel;

require __DIR__.'/../vendor/autoload.php';

/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';

/** @var Kernel $kernel */
$kernel = $app->make(Kernel::class);

// Run a null artisan thing just so Laravel internals can be setup properly
$status = $kernel->handle(
    $input = new Symfony\Component\Console\Input\ArrayInput([
        'command' => 'phpvms:version',
    ]),
    new Symfony\Component\Console\Output\NullOutput()
);

/** @var Cron $cron */
$cron = app(Cron::class);
$run = $cron->run();

echo json_encode([
    'count' => count($run),
    'tasks' => $run,
]);
