Closed nguyentranchung closed 4 years ago
I debugged the result
fab-cloud not registered
I try edit code
$this->callAfterResolving(Factory::class, function (Factory $factory) {
$factory->add('fontawesome-brands', [
'path' => __DIR__ . '/../resources/svg/brands',
'prefix' => 'fab',
]);
$factory->add('fontawesome-regular', [
'path' => __DIR__ . '/../resources/svg/regular',
'prefix' => 'far',
]);
$factory->add('fontawesome-solid', [
'path' => __DIR__ . '/../resources/svg/solid',
'prefix' => 'fas',
]);
$factory->registerComponents();
});
See result:
Please share how you're using the icons.
Hi @nguyentranchung, I haven't been able to replicate this issue. As @driesvints mentioned, could you share how you're using the icons?
I ran the following:
laravel new test && cd test
composer require owenvoke/blade-fontawesome
# add `{{ dd($this->compiler) }}` to `resources/views/welcome.blade.php`
@driesvints @owenvoke I tried installing a new project so no problem happened.
But the current project has a problem, I don't understand where the problem is.
I tried to register in blade-icons.php config.
<?php
return [
'sets' => [
'default' => [
'path' => 'resources/svg',
'prefix' => 'icon',
'class' => '',
],
'fontawesome-brands' => [
'path' => 'vendor/owenvoke/blade-fontawesome/resources/svg/brands',
'prefix' => 'fab',
'class' => 'icon',
],
'fontawesome-regular' => [
'path' => 'vendor/owenvoke/blade-fontawesome/resources/svg/regular',
'prefix' => 'far',
'class' => 'icon',
],
'fontawesome-solid' => [
'path' => 'vendor/owenvoke/blade-fontawesome/resources/svg/solid',
'prefix' => 'fas',
'class' => 'icon',
],
],
'class' => '',
];
throw CannotRegisterIconSet
I tried to register in blade-icons.php config.
You don't need to do that. The package does that for you.
You still haven't shared how you're using the icons. Please share the code and tell us where and how it's being used.
@driesvints in TestController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Blade;
class TestController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
{
dump(\Blade::debug());
return view('test');
}
}
test.blade.php
<x-fas-cloud />
That's it
in vendor\owenvoke\blade-fontawesome\src\BladeFontAwesomeServiceProvider.php I add 1 line
<?php
declare(strict_types=1);
namespace OwenVoke\BladeFontAwesome;
use BladeUI\Icons\Factory;
use Illuminate\Support\ServiceProvider;
final class BladeFontAwesomeServiceProvider extends ServiceProvider
{
public function boot(): void
{
$this->callAfterResolving(Factory::class, function (Factory $factory) {
$factory->add('fontawesome-brands', [
'path' => __DIR__ . '/../resources/svg/brands',
'prefix' => 'fab',
]);
$factory->add('fontawesome-regular', [
'path' => __DIR__ . '/../resources/svg/regular',
'prefix' => 'far',
]);
$factory->add('fontawesome-solid', [
'path' => __DIR__ . '/../resources/svg/solid',
'prefix' => 'fas',
]);
// ---------------------------------
$factory->registerComponents();
});
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../resources/svg' => public_path('vendor/blade-fontawesome'),
], 'blade-fontawesome');
}
}
}
It will be ok.
That method is already called in the main package, so I don't see why it would need to be called again. ๐ค Any thoughts @driesvints?
And then I comment out it, it's still ok.
Because cache views
After call
php artisan view:clear
This is my composer
{
"require": {
"php": "^7.2.5",
"artesaos/seotools": "^0.17.2",
"calebporzio/sushi": "^2.0",
"davejamesmiller/laravel-breadcrumbs": "^5.3",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"glorand/laravel-model-settings": "^3.6",
"guzzlehttp/guzzle": "^6.3",
"jenssegers/agent": "^2.6",
"kalnoy/nestedset": "^5.0",
"kub-at/php-simple-html-dom-parser": "^1.9",
"laracasts/flash": "^3.1",
"laravel/framework": "^7.0",
"laravel/scout": "^8.0",
"laravel/socialite": "^4.4",
"laravel/tinker": "^2.0",
"nwidart/laravel-modules": "^7.1",
"owenvoke/blade-fontawesome": "^1.1",
"spatie/enum": "^2.3",
"spatie/laravel-html": "^2.26",
"spatie/laravel-medialibrary": "^7.19",
"spatie/laravel-menu": "^3.5",
"spatie/laravel-permission": "^3.13",
"spatie/laravel-query-builder": "^2.8",
"spatie/laravel-sitemap": "^5.7",
"spatie/laravel-sluggable": "^2.2",
"spatie/laravel-tags": "^2.6",
"spatie/schema-org": "^2.14",
"spatie/valuestore": "^1.2"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.3",
"barryvdh/laravel-ide-helper": "^2.7",
"beyondcode/laravel-query-detector": "^1.3",
"facade/ignition": "^2.0",
"fzaninotto/faker": "^1.9.1",
"laravel/telescope": "^3.5",
"laravel/ui": "^2.0",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5",
"predis/predis": "^1.1"
}
}
Is there any possibility of a conflict with another package?
@driesvints @owenvoke
The problem occurs because provider BladeIconsServiceProvider runs before BladeFontAwesomeServiceProvider
But in a completely new project, I got the opposite result
@driesvints @owenvoke I found the cause, this error will appear when you install the https://github.com/jeroennoten/Laravel-AdminLTE package.
@nguyentranchung, thanks for your thorough debugging of this. ๐ค
~Just trying to create a reproducible repository for testing, but the almasaeed2010/adminlte
package isn't downloading from dist or source. ๐~
I've created a reproducible example in the following repository: https://github.com/owenvoke/blade-fontawesome-adminlte-example
I'll have a look into this, not sure what would be causing this. ๐ค @driesvints, any thoughts? I haven't experienced this with any other packages I've used.
Erhm, can anyone walk me through what the adminlte package does and how it affects icons?
@driesvints @owenvoke https://github.com/jeroennoten/Laravel-AdminLTE/blob/f860d992548048836d554bfca170fde19f1c3089/src/AdminLteServiceProvider.php#L43
Because function boot injects view factory, so view is not resolved.
I'm guessing this would probably be solved if we bound Illuminate\Contracts\View\Factory
instead. Can anyone try replacing
private function bootComponents(): void
{
$this->callAfterResolving('view', function ($view, Application $app) {
$app->make(Factory::class)->registerComponents();
});
}
with
private function bootComponents(): void
{
$this->callAfterResolving(\Illuminate\Contracts\View\Factory::class, function ($view, Application $app) {
$app->make(Factory::class)->registerComponents();
});
}
locally instead to see if that solved the problem?
@driesvints, just tested that and it doesn't seem to resolve the issue. ๐ค
I'm assuming you were meaning to try changing that in the Blade Icons service provider?
yeah that's what I meant
Yeah, it still throws the same error about the component not being found. ๐ฌ
I think I know where the problem lies. Can you try moving
private function bootComponents(): void
{
$this->callAfterResolving(\Illuminate\Contracts\View\Factory::class, function ($view, Application $app) {
$app->make(Factory::class)->registerComponents();
});
}
To the register
method instead?
I've moved it into the register
method however it still seems to throw the error. ๐คจ Apologies for taking up so much of your time.
No worries. I'll try it out myself when I find some free time. Appreciating any help until then.
I've found the issue. The problem is indeed boot
of Admin LTE getting executed before boot
of blade-fontawesome. All callAfterResolving
belong in register
actually. I didn't thought this through enough. I'll pr a fix and patch up blade-icons
as well.
Sent in https://github.com/owenvoke/blade-fontawesome/pull/9 which solves this.
Just upgraded my laravel installation to V8.x. i am getting the same error when running php artisan optimize, it happens when laravel tries to cache the views.
Unable to locate a class or view for component [fas-eye].
on \src\Illuminate\View\Compilers\ComponentTagCompiler.php:274
The wierd thing is that i do not get any errors when running php artisan view:cache on its own.
so i added
dd($this->aliases);
at vendor/laravel/framework/src/Illuminate/View/Compilers/ComponentTagCompiler.php:249
when i ran php artisan view:cache i get a long list of components, but when i ran php artisan optimize i only got
array:1 [ "dynamic-component" => "Illuminate\View\DynamicComponent" ]
I will try to find out what is happening, i am using:
blade-ui-kit/blade-icons 0.4.5 owenvoke/blade-fontawesome v1.5.0
@ahmeddabak we have the same issue on heroicons (and probably every blade icons library). I'm puzzled at what's causing this and appreciating any help.
Description
I installed as instructed, but encountered an error
Facade\Ignition\Exceptions\ViewException Unable to locate a class or view for component [fas-cloud].
Environment