03.12.2015 Views

laravel4cookbook

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

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

Multisites 201<br />

.<br />

This site definition assumes you are using PHP5 FPM. Getting this installed and running is out of<br />

the scope of this tutorial, but there are plenty of great tutorials on the subject.<br />

.<br />

You can learn more about virtual host entries, in Nginx, at: https://www.digitalocean.com/community/articles/howto-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts–3.<br />

Environments<br />

Laravel 4 employs a system of execution environments. Think of these as different contexts in which<br />

different configuration files will be loaded; determined by the host name of the machine or command<br />

flags.<br />

To illustrate this concept; think of the differences between developing and testing your applications<br />

locally and running them on a production server. You will need to target different databases, use<br />

different caching schemes etc.<br />

This can be achieved, deterministically, by setting the environments to match the host names of the<br />

machines the code will be executed (local and production respectively) and having different sets of<br />

configuration files for each environment.<br />

When a Laravel 4 application is executed, it will determine the environment that you are running it<br />

in, and adjust the path to configuration files accordingly. This approach has two caveats.<br />

The first caveat is that the PHP configuration files in app/config are always loaded and environmentbased<br />

configuration files are then loaded on top of them. If you have a database set up in app/config/database.php<br />

and nothing in app/config/production/database.php, the global database<br />

configuration details will apply.<br />

The second caveat is that you can override the environment Laravel 4 would otherwise use by<br />

supplying an environment flag to artisan commands:<br />

1 php artisan migrate --env=local<br />

This will tell artisan to execute the database migrations in the local environment, whether or not<br />

the environment you are running it in is local.<br />

This is important to multisites because Laravel 4 configuration files have the ability to connect<br />

to different database, load different views and send different emails based on environmental<br />

configuration.

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

Saved successfully!

Ooh no, something went wrong!