HollyIT / filament-static-assets

Allows Filament static assets (css, js) to be served directly from /public
MIT License
15 stars 3 forks source link

Install error #6

Open invaders-xx opened 2 years ago

invaders-xx commented 2 years ago

Just installed the package and got :

Call to undefined method HollyIT\FilamentStaticAssets\FilamentStaticManager::addContext()

HollyIT commented 2 years ago

Can you provide a full backtrace? The FilamentStaticManager doesn't have an addContext() method, nor does this package make such a call anywhere. I just searched the Filament codebase and there's no addContext() methods or calls in that either, so it sounds like you got another package or code somewhere making a bad call.

invaders-xx commented 2 years ago

Since I am using https://github.com/artificertech/filament-multi-context, I think this is where the error comes from

HollyIT commented 2 years ago

Yeah, that is actually decorating the base service class, whereas this is extending it. I just created a new decorator branch to try and switch this over to decorating the Filament service instead. If you could test this branch and let me know, I can tag new release switching to this method.

https://github.com/HollyIT/filament-static-assets/tree/decorator

invaders-xx commented 2 years ago

I am not a composer expert : which composer require format I should use ?

HollyIT commented 2 years ago

composer require "hollyit/filament-static-assets":"dev-decorator"

You can also update your composer.json manually and change the version constraint (ie: "^0.1.3") to "dev-decorator" then simply run a composer update to pull in the branch.

invaders-xx commented 2 years ago

I got

TypeError

  HollyIT\FilamentStaticAssets\FilamentStaticManager::__construct(): Argument #1 ($filament) must be of type Filament\FilamentManager, Artificertech\FilamentMultiContext\FilamentMultiContextManager given, called in /Users/david/sites/egotrace5/vendor/hollyit/filament-static-assets/src/StaticAssetsServiceProvider.php on line 16

  at vendor/hollyit/filament-static-assets/src/FilamentStaticManager.php:20
     16▕     use ForwardsCalls;
     17▕
     18▕     private FilamentManager $filament;
     19▕
  ➜  20▕     public function __construct(FilamentManager $filament)
     21▕     {
     22▕         $this->filament = $filament;
     23▕     }
     24▕

      +17 vendor frames
  18  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(AlperenErsoy\FilamentExport\FilamentExportServiceProvider))

      +5 vendor frames
  24  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
HollyIT commented 2 years ago

I was kind of afraid of that. Running multiple decorators on a base class that doesn't have an interface gives no concrete way to type things. Even if I remove the typing bindings, there's no way to test what should be returned from the underlying class.

Sadly the only way I can see to get it working is for Filament to add an interface to the FilamentManager class. I'm really hoping they improve the handling of JS and CSS in v3, preferably by utilizing an independent service class to handle all that stuff.

invaders-xx commented 2 years ago

No worries, I can wait for V3