Minimum Viable Local Environment Setup for Laravel Development With PHP, Node.js, MySQL, And Redis
To follow along I recommend either a Linux machine or a virtual machine with fresh Ubuntu installed (Virtualbox recommended).
VM has the advantage that your work environment is isolated from the personal environment, and can be easily snapshotted and rolled back in case of any trouble.
In this part of my series, we will install a minimum viable local environment for Laravel development.
A list of things I cover in this series:
- What makes PhpStorm your perfect IDE for productivity?
- Minimum viable local environment setup for Laravel development with PHP, Node.js, MySQL, and Redis.
- Recommended plugins for PhpStorm. Turn your IDE into a powerhouse for Laravel development.
- Must have composer packages for Laravel developers.
- Setting up developer tools and packages within PhpStorm for Laravel.
Here we install 2 versions of PHP binaries and we’ll learn how to switch between them. Most modern projects would be 8.0 or 8.1 versions of PHP so it’s OK to have them both installed.
Next, we will install Node.js binaries and also will learn how to switch versions with nvm (node version manager).
We will then launch common supporting services for Laravel applications — MySQL database and Redis database via Docker.
Finally, we will install a clean version of PhpStorm.
PHP 8.0 and PHP 8.1 binaries installation
Node.js: NVM and NPM install
First, we need to install the Node version manager package.
Check the current LTS version here https://nodejs.org/en/
In the next part, we will install all required services including Docker, and start commonly used development services like MySQL and Redis databases.
Docker
Just follow the guides below until you can successfully run a hello-world container.
MySQL database
We will launch a docker instance of MySQL database.
Visit https://hub.docker.com/_/mysql for more info.
When using the DatabaseMigrations
trait in testing and a schema:dump
command, you would need to install MySQL tools so Laravel can run them locally.
sudo apt install mysql-client-core-8.0
Redis database
Visit https://hub.docker.com/_/redis for information on the Redis container.
Below are my recommended apps for managing DBs in Ubuntu. Both tools have SSH tunneling for Production networks behind firewalls.
MySQL Workbench
Visit https://dev.mysql.com/downloads/workbench/ to download your version or snap:
sudo snap install mysql-workbench-community
sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service
Redis Desktop Manager
Visit https://resp.app/ for more info.
sudo snap install redis-desktop-manager
PhpStorm
Finally, we finish by installing a fresh copy of PhpStorm.
sudo snap install phpstorm --classic
or https://www.jetbrains.com/help/phpstorm/installation-guide.html#snap