#"There are no commands defined in the "icons" namespace." when called via Widget Class

16 messages · Page 1 of 1 (latest)

thick birch
#

I have created a custom widget to execute some commands like sitemap generation, build caches, nuke caches. However, I am getting a namespace error. I have tried referencing command class in Artisan::call() but it didn't help.

Here's my code


    public function buildCaches() : int
    {
        $exitCode = Artisan::call('filament:optimize');
        return $exitCode;
    }

    public function nukeCaches() : int
    {
        $exitCode = Artisan::call('filament:optimize-clear');
        return $exitCode;
    }
quartz plinthBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

thick birch
#

This seems to be problem with icon commands (caching & clearing), icons:cache called within filament:optimize
& icons:clear called within filament:optimize-clear.

#

"There are no commands defined in the "icons" namespace." when called via Widget Class

wintry yacht
#

there is a condition for these commands its only run on console:
if ($this->app->runningInConsole())

so you'll need to register the command manually
in app.php

->withCommands([
    \BladeUI\Icons\Console\CacheCommand::class,
    \BladeUI\Icons\Console\ClearCommand::class,
])
thick birch
wintry yacht
thick birch
#

Thank you. It worked

quartz plinthBOT
thick birch
#

However, Another problem is running laravel offered optimize command.

Request takes very long time and when response is received, it breaks the page. Page is not interactble anymore. Trying to click buttons show error in console:

livewire.js?id=cc800bf4:4559 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at get children (livewire.js?id=cc800bf4:4559:29)
    at getDeepChildren (livewire.js?id=cc800bf4:9066:15)
    at getDeepChildrenWithBindings (livewire.js?id=cc800bf4:9049:5)
    at livewire.js?id=cc800bf4:9008:7
    at Set.forEach (<anonymous>)
    at Array.<anonymous> (livewire.js?id=cc800bf4:9006:13)
    at trigger2 (livewire.js?id=cc800bf4:3940:34)
    at CommitBus.createAndSendNewPool (livewire.js?id=cc800bf4:4178:7)
    at livewire.js?id=cc800bf4:4158:16

I have singled out the commands and it seems view:cache & config:cache are the one which cause the problem.

My guess is that trying to build the caches invalidates current page and hence causes problem.

wintry yacht
#

are you running these command from a the browser?

thick birch
wintry yacht
#

I guess that can make some errors, if you refresh the page it will work fine without errors right?
dont understand why you want the end user to run these commands kinda dangers, it should be run with the deployment

thick birch
wintry yacht
#

I understand the need to flush some cache, but cacheing the views, config, icons, kinda high level to be done, these will affect all active sessions
just my thoughts on the subject, I am sure you know what you're doing 🙂

you can refresh the page after running the action.

thick birch
#

Caching has destroyed me more than relationships... So I tend to clear all cache & rebuild all!

I've checked the exit code and it's 0. So it seems like my guess is correct, page needs to be refreshed after the action is done.