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

nikocraft's avatar

call Artisan command that has no name for the one and only option

How would I execute command like this from the Controller:

Package I am using that gives the below artisan commands: https://github.com/JosephSilber/page-cache

php artisan page-cache:clear {slug}

for example if typed manually

php artisan page-cache:clear about-us

Laravel docs gives us this: https://laravel.com/docs/5.6/artisan#programmatically-executing-commands

Artisan::call('email:send', [
    'user' => 1, '--queue' => 'default'
]);

Since the artisan command page-cache:clear does not take any named parameters, how do I send the slug parameter to it?

I've tried this:

Artisan::call('page-cache:clear ' . $content->slug);

and get back this error:

Command "page-cache:clear hem" is not defined.↵↵Did you mean this?↵    page-cache:clear

and also I've tried this:

Artisan::call('page-cache:clear', [$content->slug]);

but then slug is not added and it calles

php artisan page-cache:clear without slug so this package clears all the cached files.

0 likes
0 replies

Please or to participate in this conversation.