diglactic / laravel-breadcrumbs

Laravel Breadcrumbs - A simple Laravel-style way to create breadcrumbs.
https://packagist.org/packages/diglactic/laravel-breadcrumbs
MIT License
868 stars 63 forks source link

Class not found #18

Closed webhostingsrbijaRS closed 3 years ago

webhostingsrbijaRS commented 3 years ago

Hello i installed, tried but i get error: Class Breadcrumbs not found in view blade file. I tried: #class-breadcrumbs-not-found

Discovered Package: diglactic/laravel-breadcrumbs

routes/breadcrumbs.php

Breadcrumbs::for('home', function ($trail) {
    $trail->push('Home', route('home'));
});

I tried to set in controller like:

$data['breadcrumbs'] = Breadcrumbs::generate();
view("view.blade.php",["data"=>$data]);

Then i get Class 'Diglactic\Breadcrumbs\Breadcrumbs' not found what i also can do?

Laravel 8 PHP 7.4 Apache OS CentOS 8

shengslogar commented 3 years ago

Try running composer dump-autoload and see if the error persists.

webhostingsrbijaRS commented 3 years ago

The same. Also tried clear cache

composer dump-autoload
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: barryvdh/laravel-dompdf
Discovered Package: diglactic/laravel-breadcrumbs

Also i tried in layout to call Breadcrumbs::generate() the same like in first comment

shengslogar commented 3 years ago

Hm, not sure what's happening here. If you feel comfortable sharing your project code (private, can add me temporarily), I can try and debug for you.

When you get Class 'Diglactic\Breadcrumbs\Breadcrumbs' not found inside your controller, are you importing it with a use Diglactic\Breadcrumbs\Breadcrumbs statement?

webhostingsrbijaRS commented 3 years ago

Unfortunately there are a lot of sensitive data so i can't share source code. Yes use Diglactic\Breadcrumbs\Breadcrumbs; is at top

namespace App\Http\Controllers;

use App\Models\DataModel;
use Diglactic\Breadcrumbs\Breadcrumbs;
use Illuminate\Http\Request;
use App\Http\Controllers\MailController;
use Illuminate\Support\Facades\Auth;

Even (PHPStorm) see that class (screenshot below) screenshot1 screenshot2

shengslogar commented 3 years ago

What composer --version are you running?

webhostingsrbijaRS commented 3 years ago

composer --version Composer version 2.0.9 2021-01-27 16:09:27

shengslogar commented 3 years ago

The other thing you might try is rm -rf your vendor folder (maybe even composer.lock) and running composer install again. Let me double-verify on my machine with Composer 2.

shengslogar commented 3 years ago

Working for me on Composer 2. You're running v6.1.0 of breadcrumbs? I can't really help further without seeing your code, but you might try creating a brand new Laravel project and seeing if the problem persists. That would tell you if something outside of this package is causing this.

webhostingsrbijaRS commented 3 years ago

Tried also with vender and composer.lock. First i had composer 1 but i updated i tought that will fix this. OK thank you for your time.

mariapaulinar commented 3 years ago

This still persist for me :(

shengslogar commented 3 years ago

@mariapaulinar This hasn't been a reproducible issue. What version of the following are you using?

Can you share code that caused this exception to be thrown?

mariapaulinar commented 3 years ago

Hello. Here my config:

Composer: image

PHP: image

Laravel: image

Laravel Breadcrumb: image

shengslogar commented 3 years ago

@mariapaulinar Thanks. What are the steps leading up to to this exception being thrown?

mariapaulinar commented 3 years ago

My error! I wasn't using the namespace on breadcrumbs.php. Sorry!