MariaJen
MariaJen

Reputation: 1143

Laravel run package artisan command in controller

I need to run this command when user change something in translation file

php artisan export:messages-flat

I need to add it in may controller

so I'm using this code

\Artisan::call('export:messages-flat');

but it return error saying that

The command "export:messages-flat" does not exist.

but when I

php artisan list

enter image description here

it's in the list

I also try to run other command

\Artisan::call('cache:clear');

and it works

this is the package I'm using link

kindly help me, sorry for may poor english

Upvotes: 0

Views: 1528

Answers (2)

Osta
Osta

Reputation: 177

If someone needs answer for this just register command in the app\Console\Kernel.php because it is not registered automatically:

protected $commands = [
        ExportMessagesToFlat::class
    ];

Upvotes: 1

waterloomatt
waterloomatt

Reputation: 3742

The package only allows you to run the commands from the CLI. You can see from the source code, they only register the Artisan commands if the application is running from the console.

As an alternative, you can call ExportLocalization::export()->toFlat() according to their documentation.

Upvotes: 0

Related Questions