Slim 3 console execution for cron
<p>I'm trying to create some kind of import to move database info and transform data. In the future this import needs to be executed by cron every day. I want to use part of my written code and reuse some models and controllers. To do this I'm trying to call Slim 3 through the command line, but I have some problems.</p>
<p>console command:</p>
<pre><code> php cli.php import
</code></pre>
<p>I don't know how to process <em>argv</em> correctly.</p>
<h3>cli.php:</h3>
<pre><code>require __DIR__ . '/vendor/autoload.php';

if (PHP_SAPI == 'cli') {
    $argv = $GLOBALS['argv'];
    array_shift($argv);

    $pathInfo       = implode('/', $argv);

    $env = \Slim\Http\Environment::mock(['PATH_INFO' =&gt; $pathInfo]);

    $settings = require __DIR__ . '/app/config/settings.php'; // here are return ['settings'=&gt;'']

    //I try adding here path_info but this is wrong, I'm sure
    $settings['environment'] = $env; 

    $app = new \Slim\App($settings);

    $container = $app-&gt;getContainer();
    $container['errorHandler'] = function ($c) {
        return function ($request, $response, $exception) use ($c) {
             //this is wrong, i'm not with http
             return $c['response']-&gt;withStatus(500)
                  -&gt;withHeader('Content-Type', 'text/text')
                  -&gt;write('Something went wrong!');
        };
    };

    $container['notFoundHandler'] = function ($c) {
        //this is wrong, i'm not with http
        return function ($request, $response) use ($c) {
            return $c['response']
                -&gt;withStatus(404)
                -&gt;withHeader('Content-Type', 'text/text')
                -&gt;write('Not Found');
        };
    };

    $app-&gt;map(['GET'], 'import', function() {
       // do import calling Actions or Controllers
    });
}
</code></pre>
<p>If I execute this I see a <em>404 Page not found</em> error.</p>
<p>Any directions?</p>