Comments (9)
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.
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.
So, you would be correct. For some reason my boot() is being called before yours.
from laravel-breadcrumbs.
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.
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.
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.
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.
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.
Great thanks for the update!
from laravel-breadcrumbs.
Related Issues (20)
- Dynamic breadcrumb - Trying to get property of non-object HOT 1
- Error logging
- Feature Request: Be able to pass the register name to the call back function HOT 1
- After execute the publish command, the config file not appear HOT 1
- json-ld Unspecified Type HOT 2
- Error en Ubuntu HOT 2
- Same errors with $breadcrumbs HOT 2
- Generate breadcrumbs for tabbed content HOT 4
- Wrong Readme Method parameter reference
- Method for does not exist. HOT 2
- can't get post category HOT 12
- How to pass the value to the bread crumbs with my admin panel? HOT 1
- It would be nice if I could put icons like this: HOT 1
- Laravel 5.7 Released HOT 1
- Add Laravel 5.7 support HOT 1
- installed the package and got Class 'Breadcrumbs' not found error HOT 2
- Feature Request UIKit breadcrumbs HOT 6
- Does this package even works??? HOT 3
- "Home" breadcrumb shows up twice, unable to remove it HOT 3
- breadcrumb 4 levels HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-breadcrumbs.