The latest up-to-date instructions to install Laravel can always be found at the Laravel website, http://laravel.com. To begin using Laravel in a development environment, the current best practices suggest using the following:
The basic process involves downloading and installing Composer and then adding Laravel as a dependency. An important detail is that the storage directory, which is located parallel to the /app
directory, needs to be set in such a way that it is writable by the web server user in order to allow Laravel 5 to do things like writing the log files. It is also important to make sure that $ php artisan key:generate
is used to generate a 32-character key that is used for hashing because, since the release of PHP 5.6, Mcrypt is more strict as regards its requirements. For Laravel 5.1, OpenSSL will replace Mcrypt.
In Laravel 4, the environments were configured in a manner that relied on the hostname of the server or a development machine, and this was rather contrived. Laravel 5 instead uses a .env
file that sets up the various environments. This file is included in .gitignore
. Thus, each machine should receive its configuration from a source outside the source code control.
So for example, something like the following code can be used to set up a local development:
APP_ENV=local APP_DEBUG=true APP_KEY=SomeRandomString DB_HOST=localhost DB_DATABASE=example DB_USERNAME=DBUser DB_PASSWORD=DBPass CACHE_DRIVER=file SESSION_DRIVER=file
A nice new feature of Laravel is that it allows you to set the highest level namespace to something such as MyCompany
through the app:name
command. This command will actually change the namespace of all the relevant files inside the /app
directory from App to MyCompany
, for example. This namespace then lives inside the /app
directory. This builds namespacing right into virtually every file whereas previously, in version 4.x, it was optional.