29.07.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Package Development 302<br />

.<br />

11 }<br />

Now, when users of your package execute Laravel’s vendor:publish command, your file will be<br />

copied to the specified location. Of course, once your configuration has been published, it can be<br />

accessed like any other configuration file:<br />

.<br />

1 $value = config('courier.option');<br />

Default Package Configuration<br />

You may also choose to merge your own package configuration file with the application’s copy. This<br />

allows your users to include only the options they actually want to override in the published copy<br />

of the configuration. To merge the configurations, use the mergeConfigFrom method within your<br />

service provider’s register method:<br />

.<br />

1 /**<br />

2 * Register bindings in the container.<br />

3 *<br />

4 * @return void<br />

5 */<br />

6 public function register()<br />

7 {<br />

8 $this->mergeConfigFrom(<br />

9 __DIR__.'/path/to/config/courier.php', 'courier'<br />

10 );<br />

11 }<br />

Public Assets<br />

Your packages may have assets such as JavaScript, CSS, and images. To publish these assets to the<br />

application’s public directory, use the service provider’s publishes method. In this example, we<br />

will also add a public asset group tag, which may be used to publish groups of related assets:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!