-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to locate a class or view for component [fas-cloud] #6
Comments
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 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' => '',
]; |
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 <?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? |
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? |
The problem occurs because provider BladeIconsServiceProvider runs before BladeFontAwesomeServiceProvider |
@driesvints @owenvoke |
@nguyentranchung, thanks for your thorough debugging of this. 🤔
I've created a reproducible example in the following repository: 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 Because function boot injects view factory, so view is not resolved. |
I'm guessing this would probably be solved if we bound 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 |
I've moved it into the |
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 |
Sent in #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 [ I will try to find out what is happening, i am using: blade-ui-kit/blade-icons 0.4.5 |
@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
The text was updated successfully, but these errors were encountered: