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.

Installation 45<br />

Configuration Caching<br />

To give your application a speed boost, you should cache all of your configuration files into a single<br />

file using the config:cache Artisan command. This will combine all of the configuration options<br />

for your application into a single file which can be loaded quickly by the framework.<br />

You should typically run the php artisan config:cache command as part of your production<br />

deployment routine. The command should not be run during local development as configuration<br />

options will frequently need to be changed during the course of your application’s development.<br />

Accessing Configuration Values<br />

You may easily access your configuration values using the global config helper function. The<br />

configuration values may be accessed using “dot” syntax, which includes the name of the file<br />

and option you wish to access. A default value may also be specified and will be returned if the<br />

configuration option does not exist:<br />

.<br />

1 $value = config('app.timezone');<br />

To set configuration values at runtime, pass an array to the config helper:<br />

.<br />

1 config(['app.timezone' => 'America/Chicago']);<br />

Naming Your Application<br />

After installing Laravel, you may wish to “name” your application. By default, the app directory<br />

is namespaced under App, and autoloaded by Composer using the PSR-4 autoloading standard³³.<br />

However, you may change the namespace to match the name of your application, which you can<br />

easily do via the app:name Artisan command.<br />

For example, if your application is named “Horsefly”, you could run the following command from<br />

the root of your installation:<br />

.<br />

1 php artisan app:name Horsefly<br />

³³http://www.php-fig.org/psr/psr-4/

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

Saved successfully!

Ooh no, something went wrong!