Git Product home page Git Product logo

Comments (9)

d13r avatar d13r commented on June 2, 2024

I can't see anything obviously wrong. I wonder if your boot() method is being called before mine somehow? From the order of service providers in the config it looks like that shouldn't be the case, but I'm not sure what Laravel does internally that might affect it...

from laravel-breadcrumbs.

sniper7kills avatar sniper7kills commented on June 2, 2024

I don't expect you to know the answer to this, but have to ask anyway. From Laravel 4.1 to Laravel 4.2 did anything change in $app['config']?

public function register()

    {

        $this->app['breadcrumbs'] = $this->app->share(function($app)

        {

            $breadcrumbs = new Manager($app['view'], $app['router']);

            //die("<pre>".print_r($app['config'],true));
            //die("<pre>".print_r(\Config::get('laravel-breadcrumbs::view'),true));
            $breadcrumbs->setView($app['config']['laravel-breadcrumbs::view']);



            return $breadcrumbs;

        });

    }

Both of my test outputs don't show anything from your package.

from laravel-breadcrumbs.

sniper7kills avatar sniper7kills commented on June 2, 2024

So, you would be correct. For some reason my boot() is being called before yours.

from laravel-breadcrumbs.

sniper7kills avatar sniper7kills commented on June 2, 2024

Got it. protected $defer = true; Needs to be protected $defer = false; in your ServiceProvider

I'll have to look further into that personally for my knowledge.

from laravel-breadcrumbs.

d13r avatar d13r commented on June 2, 2024

That's strange, but perhaps gets us closer to an answer. My understanding of $defer is it means the package won't be loaded until someone calls "Breadcrumbs::something()". Since your package loads breadcrumbs.php which calls Breadcrumbs::register(), it should get loaded at that point. But perhaps there's some issue that makes Laravel not call it correctly when loaded from another service provider...

My first thought would be to debug Laravel to find the root cause - right now it sounds to me like a Laravel bug - but that could be a lot of effort so I could just set $defer = false. (I don't think there should be any side-effects, other than doing a little unnecessary work registering breadcrumbs on pages that don't need them.)

from laravel-breadcrumbs.

stevebauman avatar stevebauman commented on June 2, 2024

Yea this is happening to me on 4.2 as well. Setting defer to false doesn't solve the issue for me. This seems to be an issue with the different names you're using in your service provider.

On line 22 and line 32 you're using breadcrumbs as the package alias, but in your provides function you're telling laravel the package is laravel-breadcrumbs.

I believe laravel parses the provides array for aliasing prefixes for packages, such as:

package::config-entry

So in this case it's looking for breadcrumbs::view on line 36. However this doesn't work either because of the clashing lines mentioned above (22, 32).

Unfortunately I don't have time at the moment to debug this, but I'm 99% sure that this is the issue. I've loaded lots of laravel packages, and every single one of them have a constant name inside their service provider.

Throwing in laravel-breadcrumbs::bootstrap3 into the $breadcrumbs->setView() on line 36 in the service provider does fix this issue, so it's definitely something to do with your package being registered in the configuration instance. From inside your package I can use the same config instance to call my own packages configuration and my values are returned just fine.

from laravel-breadcrumbs.

d13r avatar d13r commented on June 2, 2024

Sounds possible. If so it's quite tedious because I originally named everything "breadcrumbs", except I used "laravel-breadcrumbs" in Composer to make it easier to find - but that triggered a bug in Laravel because the package folder name didn't match the config filename! I can't find the bug report right now, but Taylor wouldn't fix it so I had to rename them to "laravel-breadcrumbs" instead (#11).

Anyway, I'm not planning to spend any more time on this because Laravel 5 will probably change everything (#62). But if you can find a solution do make a PR and I'll merge it.

from laravel-breadcrumbs.

d13r avatar d13r commented on June 2, 2024

Fixed in 2.3.1 (Laravel 4) and 3.0.0 (Laravel 5).

I'm pretty sure it is a bug in Laravel, and still occurs in Laravel 5, but I settled for working around it by setting $defer = false.

from laravel-breadcrumbs.

stevebauman avatar stevebauman commented on June 2, 2024

Great thanks for the update!

from laravel-breadcrumbs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.