Install Laravel 5.1 on OSX with MAMP

I tried installing Laravel 5.1 on OSX Yosemite using MAMP and ran a couple of road blocks. In particular, when I tried to migrate the database, I received the following error.

[PDOException] SQLSTATE[HY000] [2002] No such file or directory 
+7
mamp laravel macos
source share
3 answers

1) Install Composer

If you do not already have a composer installed, you will need to do this. You can check the weather you created the composer by simply typing the composer command in the mac terminal . You should see a list of available commands if composer is installed.

Screen Shot 2015-08-17 at 1.34.05 PM.png

If you don’t have a composer yet, you can see Getting started with Composer

2) Install Laravel

Laravel has good documentation on installing Laravel . I will go exactly what steps I took to launch Laravel on OSX Yosemite.

Install through the Laravel installer. Enter the following into the terminal.

 cd ~/ composer global require "laravel/installer=~1.1" 

Add the composer executable to the Path environment so that you can find the laravel .

 PATH=$PATH:~/.composer/vendor/bin 

Install a new Laravel instance and give it a name. In our case, we will call the saas project.

 laravel new saas 

I use MAMP PRO to run sites locally on my mac. So I just need to create a new host in MAMP and point it to the saas / public directory.

laravel_mamp.png

Then, visiting http: // saas: 8888 , you will see a beautiful Laravel welcome screen.

laravel5_1.png

3) Create a database

I like to use Navicat to manage my databases. With Navicat for MySQL, I create a new local database.

Then define this connection in the .env file.

  DB_HOST=localhost DB_DATABASE=saas DB_USERNAME=root DB_PASSWORD=xxxxxxx 

Start the migration with the following command:

 php artisan migrate 

Since I use MAMP, I got this error while trying to migrate.

 [PDOException] 

SQLSTATE [HY000] [2002] There is no such file or directory

The solution was to add the unix_socket key with the value of the path where mysql.sock is in MAMP .

 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock', ], 

4) Wrap-UP

The directories in the repository and the bootstrap / cache directories must be writable. We will do this with the following:

 chmod -R 777 storage chmod -R 777 bootstrap/cache 

Rename the environment file.

 mv .env.example .env 

5) PHP path

Since we used MAMP, we have several versions of PHP installed on our machine. Therefore, if we try to run php artisan , we will be given an error.

 Mcrypt PHP extension required 

If you also get this error, first check which version of PHP you are using with MAMP. You can check this through the main MAMP> PHP window. In my case, they used version 5.6.10 .

Then we can edit our ~/.bash_profile file by adding the following line:

 export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH 

Reboot the terminal and then you can run the php artisan command.

What is it. Create something awesome!

+33
source share

Adding a local configuration to a file like config / database.php seemed wrong to me - since any changes in it would also be uploaded to the Git repository.

Found this other solution that works fine without changing the code:

 mkdir /var/mysql ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock 

It worked instantly and no changes to PHP or Git -able files.

Hope this helps.

+5
source share

Laravel Framework 5.7 Install on Mac OS with MAMP

Composer Composer setting

 curl -sS https://getcomposer.org/installer | php 

Laravel installation

  1. global composer requires laravel / installer
  2. PATH = $ PATH: ~ / .composer / provider / bin
  3. Laravel new

chmod -R 775 storage chmod -R 775 loader / cache

After I got 500 errors

The checked error log found the following error

 tail -f /Applications/MAMP/logs/php_error.log 

Detected: syntax error, unexpected '=' blog/vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 388

I changed my version of php 7.1 solved my problem

0
source share

All Articles