Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

junedc's avatar

Execute PHP artisan with complex parameter from Job

I have read https://laravel.com/docs/8.x/artisan#programmatically-executing-commands already but my commands are quite complex.

this is the command if I type from terminal

php artisan tenants:run scout:import --tenants="e99f2662-5d20-4157-b45e-91fb810f1d88" --argument="model=App\Models\Tenant\Application"

I wanted 'e99f2662-5d20-4157-b45e-91fb810f1d88' and 'App\Models\Tenant\Application' to be parametized as this is different from staging and production db.

This is what I have done so far inside a job

   public function __construct(string $tenantId, string $className)
    {
        Artisan::call('tenants:run scout:import', ['tenants='  => $tenantId , 'argument'  => "model=" . $className]);
    }

this throws an error The command "tenants:run scout:import" does not exist. Thanks in advance.

0 likes
1 reply

Please or to participate in this conversation.