How solve “IlluminateConsoleCommand” not found?

I have a web application in a production environment. The path to the command is correctly set on the server, but it still throws error “IlluminateConsoleCommand” not found. Solutions tryied -> (composer dump-autoload, deleted vendor and reinstalled with composer install, php artisan optimize). Nothing works :/

Fatal error: Uncaught Error: Class “IlluminateConsoleCommand” 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 AppConsoleCommands;

use CarbonCarbon;
use IlluminateConsoleCommand;
use IlluminateSupportFacadesDB;
use IlluminateSupportFacadesLog;

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');
    }

}

This is my kernel.php

<?php

namespace AppConsole;

use IlluminateConsoleSchedulingSchedule;
use IlluminateFoundationConsoleKernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     */
    protected function schedule(Schedule $schedule): void
    {
        $schedule->command('delete-expired-data')->daily();
        // $schedule->command('delete-unconfirmed-res')->everyFiveMinutes();
    }

    /**
     * Register the commands for the application.
     */
    protected function commands(): void
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }


And this is composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": ["laravel", "framework"],
    "license": "MIT",
    "require": {
        "php": "^8.1",
        "erlandmuchasaj/laravel-gzip": "^1.0",
        "guzzlehttp/guzzle": "^7.2",
        "jantinnerezo/livewire-alert": "^3.0",
        "laravel/framework": "^10.10",
        "laravel/sanctum": "^3.3",
        "laravel/tinker": "^2.8",
        "livewire/livewire": "^3.4",
        "propaganistas/laravel-phone": "^5.0"
    },
    "require-dev": {
        "fakerphp/faker": "^1.23",
        "laravel/pint": "^1.0",
        "laravel/sail": "^1.18",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^7.0",
        "phpunit/phpunit": "^10.1",
        "spatie/laravel-ignition": "^2.0"
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan vendor:publish --force --tag=livewire:assets --ansi"

        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

I’ll be glad if anybody has idea how can I solve that issue 🙂 Thank you

So I crated this custom script in www folder

#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

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

$app = require_once __DIR__.'/bootstrap/app.php';

$commandName = 'app:delete-expired-data';

$kernel = $app->make(IlluminateContractsConsoleKernel::class);

$input = new SymfonyComponentConsoleInputArgvInput(['artisan', 'schedule:run']);

$status = $kernel->handle($input, new SymfonyComponentConsoleOutputConsoleOutput);

$kernel->terminate($input, $status);

exit($status);

In server cron log I have got this, is there any possible solution how to solve that? Because I can’t edit proc_open on server.. 🙁

Tue 05 Mar 2024 04:35:23 PM CET Executing /srv/www/myDomain//barbershop27/scheduler.php

  2024-03-05 16:35:23 Running ['artisan' delete-expired-data] ....... 8ms DONE
  ⇂ '/usr/bin/php8.2' 'artisan' delete-expired-data > '/dev/null' 2>&1  

But in storage/logs it shows this error

production.ERROR: The Process class relies on proc_open, which is not available on your PHP installation. {"exception":"[object] (SymfonyComponentProcessExceptionLogicException(code: 0): The Process class relies on proc_open, which is not available on your PHP installation. at /srv/www/myDomain/barbershop27/vendor/symfony/process/Process.php:147)
[stacktrace]
#0 /srv/www/myDomain/barbershop27/vendor/symfony/process/Process.php(192): SymfonyComponentProcessProcess->__construct(Array, '/srv/www/myDomain...', NULL, NULL, NULL)

19

Okey,, finally a I did solve that with this option, and it works! 🙂

#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

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

$app = require_once __DIR__.'/bootstrap/app.php';

$container = $app->make(IlluminateContractsContainerContainer::class);

$kernel = $container->make(IlluminateContractsConsoleKernel::class);

$commandName = 'delete-expired-data';

$input = new SymfonyComponentConsoleInputArgvInput(['console.php', $commandName]);

$status = $kernel->handle($input, new SymfonyComponentConsoleOutputConsoleOutput);

$kernel->terminate($input, $status);

exit($status);

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật