DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on • Updated on

Install PHP & MySQL in MacOS

Step 1) Install Brew

Ref: https://brew.sh/

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Step 2) Install PHP

brew install php
Enter fullscreen mode Exit fullscreen mode

To install a specific version

brew install php@8.1
Enter fullscreen mode Exit fullscreen mode

To make a specific php version as default:

brew link --overwrite --force php@8.1
Enter fullscreen mode Exit fullscreen mode

Step 3) Install PHP Extensions

brew tap shivammathur/php
Enter fullscreen mode Exit fullscreen mode
brew tap shivammathur/extensions
Enter fullscreen mode Exit fullscreen mode

Eg: Install imap

brew install imap@8.1
Enter fullscreen mode Exit fullscreen mode

To verify run:

php -m
Enter fullscreen mode Exit fullscreen mode

Step 4) Install Composer

brew install composer
Enter fullscreen mode Exit fullscreen mode

Step 5) Install Laravel Valet

Ref: https://laravel.com/docs/10.x/valet

composer global require laravel/valet
Enter fullscreen mode Exit fullscreen mode
valet install
Enter fullscreen mode Exit fullscreen mode

To change the default version of valet:

valet use php@8.1
Enter fullscreen mode Exit fullscreen mode

To verify:

valet php -v
Enter fullscreen mode Exit fullscreen mode

To install composer packages in a project root directory, run

valet composer install
Enter fullscreen mode Exit fullscreen mode

then run

valet link
Enter fullscreen mode Exit fullscreen mode

Now, you can visit: http://<project-directory>.test, it should render default page.

Step 6) MySql Database

Install DBngin from https://dbngin.com/

Step 7) Install PhpMyAdmin

$cfg['blowfish_secret'] = ''; //some random key
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Enter fullscreen mode Exit fullscreen mode

Try to open and login.

Or you can also install https://apps.apple.com/us/app/sequel-ace/id1518036000?mt=12

Top comments (1)

Collapse
 
leslieeeee profile image
Leslie

Have you tried ServBay.dev?
It's a much easier tool for PHP developers, providing a user-friendly experience, especially for beginners. It supports all versions of PHP, MariaDB, PostgreSQL, as well as Redis and Memcached. You can run multiple PHP instances simultaneously and switch between them effortlessly. It also offers easy updates without the need to configure environment variables. This tool has greatly simplified my PHP development and is definitely worth trying!