Hi, I am a fresher to Slim Framework.I want to send sms to customer through cron job using Slim-3.
Below is my code.
I have crated a file cli.php under projectFolder/Public/cli.php
<?php
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' => $pathInfo]);
$env = \Slim\Http\Environment::mock(['REQUEST_URI' => '/' . $pathInfo]);
$settings = require __DIR__ . '/app/config/settings.php'; // here are return ['settings'=>'']
//I try adding here path_info but this is wrong, I'm sure
$settings['environment'] = $env;
$app = new \Slim\App($settings);
$container = $app->getContainer();
$container['errorHandler'] = function ($c) {
return function ($request, $response, $exception) use ($c) {
//this is wrong, i'm not with http
return $c['response']->withStatus(500)
->withHeader('Content-Type', 'text/text')
->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']
->withStatus(404)
->withHeader('Content-Type', 'text/text')
->write('Not Found');
};
};
$app->map(['GET'], '/import', function() {
// do import calling Actions or Controllers
echo "Hello";
});
}
And in executing below command in the command line.
C:\xampp\htdocs\projectFolder>php public/cli.php /import
But getting error.
Kindly Help
Thanks in advanceā¦