06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Package Development 410<br />

11 __DIR__.'/path/to/translations' => resource_path('lang/vendor/courier'),<br />

12 ]);<br />

13 }<br />

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

package’s translations will be published to the specified location.<br />

Configuration<br />

Typically, you will want to publish your package’s configuration file to the application’s own config<br />

directory. This will allow users of your package to easily override your default configuration options.<br />

To publish a configuration file, just use the publishes method from the boot method of your service<br />

provider:<br />

1 /**<br />

2 * Perform post-registration booting of services.<br />

3 *<br />

4 * @return void<br />

5 */<br />

6 public function boot()<br />

7 {<br />

8 $this->publishes([<br />

9 __DIR__.'/path/to/config/courier.php' => config_path('courier.php'),<br />

10 ]);<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 />

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

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

Saved successfully!

Ooh no, something went wrong!