A few days ago, I was pulling my hair out simply because I couldn't get my configuration data. Creating packages in Laravel 4 is not as hard as it may initially seem, especially if you follow the documentation properly. I didn't, so I basically wasted around a couple of hours thinking of what I did wrong, which ended with me slacking in front of the TV.
I read the documentation again, but still didn't solve my problem. Below, I will share how I was able to get my configuration data. Note that this tip will mainly cover notes not found in Laravel's documentation. Hence, do not continue reading unless you've read the documentation or done packages.
Creating Our Package
When making packages intended for Laravel, you'd execute something like
php artisan workbench Zejesago/Laravel-Social --resources. Neat. This creates some initial package structure for you in your
From here on, I will refer to paths from the package directory,
After that, you can start coding away and including configurations. To load in configuration data from
config/facebook.php, you can use
\Config::get('laravel-social::facebook.appId');. Normally, this would just work as it should, but it didn't in my case.
I was trying to be witty, so I changed my namespace from
Zejesago\Laravel\Social\; I just like to organize it that way. Seemingly, there shouldn't be any problem with this approach. However, I also ended up moving my service provider from
I found out that
Config class could not find any configuration files from the package's path, because the parent
ServiceProvider class guesses the path from the location of the service provider. In my case,
SocialServiceProvider. All that I had to do was to explicitly state the path of the package in the
public function boot()
'zejesago/laravel-social', null, __DIR__.'/../../..');
This took me a long while to finally figure it out. The fact that the
Config class is just a facade makes it even more difficult to dissect how Laravel goes about it thing. I guess I just started at the wrong end by initially looking at
Config instead of the parent
ServiceProvider class first.
Laravel Social (now called, Laravel Facebook) is a package that I created for practice with Laravel and use with projects.