Neon Tsunami

Laravel package config/assets with PSR-4

July 02, 2014

Came across an issue today when trying to upgrade my bootstrap-form package to use PSR-4. With the new autoloader Laravel finds it difficult to find the configuration files and assets that your package might require. By default, Laravel looks two directories above where the source code is, and with PSR-4 they are actually co-located. You can read a little bit more about it, and the fact that nothing is going to be done about at it at present, here in laravel/framework issue #3505.

To fix this up, simply adjust the boot() method in your service provider, providing the 3rd parameter.

/**
 * Boot the service provider.
 *
 * @return void
 */
public function boot()
{
	$this->package('watson/bootstrap-form', null, __DIR__);
}

You should now find that everything goes back to working how you would expect!


A blog about Laravel & Rails, written by Dwight Watson.