Try to delete vendor folder and run composer install and check then if it's working or not
How solve "Illuminate\Console\Command" not found ??
Hello, I've got webapp in production enviroment, path to comman is set correctly on serveer, but it still throwing this error ->
Fatal error: Uncaught Error: Class "Illuminate\Console\Command" not found in app/Console/Commands/DeleteExpiredData.php:10
Stack trace:
#0 {main}
thrown in /app/Console/Commands/DeleteExpiredData.php on line 10
Illuminatie is available in vendor and correctly installed, I did try composer dump-autoload but it still doesn't work.
This is my command
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DeleteExpiredData extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete-expired-data';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete old data from database';
/**
* Execute the console command.
*/
public function handle()
{
$now = Carbon::now();
Log::info('Starting app:delete-expired-data command');
DB::table('available_business_hour')
->whereDate('day', '<', $now->startOfDay())
->delete();
Log::info('Expired command executed successfully');
}
}
I'll be glad if anybody has idea how can I solve that issue :) Thank you
@jakubjv Then you would need to come up with a php script that runs artisan or emulates it.
The following can be saved as scheduler.php
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any of our classes manually. It's great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput(['artisan','schedule:run']),
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);
Then run it with the cron.
You can test it with php scheduler.php and you will find its the same as artisan schedule:run
It must live in the laravel folder and not www/cron
Note that this is a copy of artisan with one line changed
new Symfony\Component\Console\Input\ArgvInput(['artisan','schedule:run']),
which passes the command the schedule:run string meaning its not needed in the cron setting
Please or to participate in this conversation.