web publishing magazine

How to install Laravel in to a MAMP PRO document root

  1. Install Composer (See
  2. Create a host laravel.test with database laravel_test in MAMP PRO
  3. Open the terminal and cd to the document root of the laravel.test host
  4. type the following in the terminal (without quotes): “composer create-project –prefer-dist laravel/laravel .” <- Make sure not to forget the dot!
  5. After installation, open the hidden file .env (which is located in the document root) in any text editor of your choice
  6. Setup the db section like this:


If you have a different user and password for mysql you need to use these instead of root/root

7. Open the file config/database.php and set database there too:

‘mysql’ => [
‘driver’ => ‘mysql’,
‘host’ => env(‘DB_HOST’, ‘localhost’),
‘port’ => env(‘DB_PORT’, ‘3306’),
‘database’ => env(‘DB_DATABASE’, ‘laravel_test’),
‘username’ => env(‘DB_USERNAME’, ‘root’),
‘password’ => env(‘DB_PASSWORD’, ‘root’),
‘unix_socket’ => env(‘DB_SOCKET’, ‘/Applications/MAMP/tmp/mysql/mysql.sock’),
‘charset’ => ‘utf8mb4’,
‘collation’ => ‘utf8mb4_unicode_ci’,
‘prefix’ => ”,
‘prefix_indexes’ => true,
‘strict’ => true,
‘engine’ => null,
‘options’ => extension_loaded(‘pdo_mysql’) ? array_filter([
]) : [],

8. Copy the hidden “.htaccess” file from the “public” folder directly in the document root of your laravel.test host

9. Rename server.php into index.php

Thats it. Now you should be able to call http://laravel.test to see the starting page of laravel

To add the default databases and tables you need to migrate them. This is done like this:

  1. Be sure MAMP PRO is running
  2. Open the terminal and cd to the document root of the laravel.test host
  3. Type “php artisan migrate”

You should see something like this:

Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table

Now everything works like described in the documentation of laravel (e.g. installing new modules, creating new migrations, etc)

If you make changes in one of the config files you always need to cd to the document root of the laravel.test host and call “php artisan config:cache” in the terminal