I'm using Artisan
to call a Laravel 5 Route
via the command line. I created a command line controller by following the directions in this post: Call laravel controller via command line.
I don't receive any errors when I navigate to this route in a web browser. This route performs an API call and inserts data into a MySQL database by using a Laravel
Model
I created called Ticker
.
When I can call my route from the CLI, like so:
$ php artisan route:call /d17059dfce4c09ef5e437b1d9455f7c6
I'm getting a Laravel
error (where truncate 'tickers'
is the first SQL command executed in the controller which the route calls, and tickers
is the table within the database), stating:
SQLSTATE[HY000] [2002] No such file or directory (SQL: truncate `tickers`)
Because I only seem to be getting the error when executing this route through the command line, it leads me to believe there must be some issue with the command line script App\Console\Commands\CallRoute.php
which looks like this:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Http\Requests;
class CallRoute extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'route:call {uri}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'php artsian route:call /route';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$request = Request::create($this->argument('uri'), 'GET');
$this->info(app()->make(\Illuminate\Contracts\Http\Kernel::class)->handle($request));
}
}
Any help troubleshooting or resolving this error would be greatly appreciated. Thank you in advance.