blade-ui-kit / blade-icons

A package to easily make use of SVG icons in your Laravel Blade views.
https://blade-ui-kit.com/blade-icons
MIT License
2.21k stars 148 forks source link

Exception when loading provider #241

Closed cherbst closed 4 months ago

cherbst commented 5 months ago

Library version

1.6.0

Laravel version

v10.*

PHP version

8.2

Description

I use this project in my wordpress plugin using acorn. When the provider is being loaded I get the following exception:

`PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Unresolvable dependency resolving [Parameter #1 [ string $manifestPath ]] in class BladeUI\Icons\IconsManifest in /vendor/illuminate/container/Container.php:1141 Stack trace:

0 /vendor/illuminate/container/Container.php(1050): Illuminate\Container\Container->unresolvablePrimitive(Object(ReflectionParameter))

1 /vendor/illuminate/container/Container.php(981): Illuminate\Container\Container->resolvePrimitive(Object(ReflectionParameter))

2 /vendor/illuminate/container/Container.php(943): Illuminate\Container\Container->resolveDependencies(Array)

3 /vendor/illuminate/container/Container.php(795): Illuminate\Container\Container->build('BladeUI\Icons\I...')

4 /vendor/roots/acorn/src/Illuminate/Foundation/Application.php(957): Illuminate\Container\Container->resolve('BladeUI\Icons\I...', Array, true)

5 /vendor/illuminate/container/Container.php(731): Illuminate\Foundation\Application->resolve('BladeUI\Icons\I...', Array)

6 /vendor/roots/acorn/src/Illuminate/Foundation/Application.php(942): Illuminate\Container\Container->make('BladeUI\Icons\I...', Array)

7 /vendor/illuminate/container/Container.php(1066): Illuminate\Foundation\Application->make('BladeUI\Icons\I...')

8 /vendor/illuminate/container/Container.php(982): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))

9 /vendor/illuminate/container/Container.php(943): Illuminate\Container\Container->resolveDependencies(Array)

10 /vendor/illuminate/container/Container.php(795): Illuminate\Container\Container->build('BladeUI\Icons\F...')

11 /vendor/roots/acorn/src/Illuminate/Foundation/Application.php(957): Illuminate\Container\Container->resolve('BladeUI\Icons\F...', Array, true)

12 /vendor/illuminate/container/Container.php(731): Illuminate\Foundation\Application->resolve('BladeUI\Icons\F...', Array)

13 /vendor/roots/acorn/src/Illuminate/Foundation/Application.php(942): Illuminate\Container\Container->make('BladeUI\Icons\F...', Array)

14 /vendor/roots/acorn/src/Illuminate/Foundation/helpers.php(120): Illuminate\Foundation\Application->make('BladeUI\Icons\F...', Array)

15 /var/www/html/vendor/blade-ui-kit/blade-icons/src/helpers.php(11): app('BladeUI\Icons\F...')

I replaced the actual path to our plugin in the logs with`.

The problem seems to be that the container cannot resolve the primitive argument $manifestPath to the IconsManifest class und thus instantiation of the IconsManifest class fails. It is working if we change the order of register methods in the BladeIconsServiceProvider::register method so that the manifest is registered before the rest of the classes by moving the call to $this->registerManifest() before the call to $this->registerFactory();. I could provide a PR that does just this if needed.

Steps to reproduce

I installed this package on a wordpress installation using acorn following this guide: https://roots.io/sage/docs/use-blade-icons/ But I guess the problem should also happen on a normal laravel installation.

driesvints commented 4 months ago

Hi there. I can't unfortunately provide support for this package. Please report this to their issue tracker.