Local development
π©π»βπ»
It works on my machine!
A local development environment is key for successful application lifetime management and continuous deployment.
# Why local development?
- See code changes in real time
- Test your code before deploying
- Debug issues with dev flags enabled
- Experiment with new features
- Validate compatibility
- Maintain an up-to-date backup
Not having a local development environment can lead to chaos. Developers may perform "open heart surgery"βrunning major updates directly on the server. The fortrabbit platform aims to make deployment from local development to remote environments seamless and safe.
# Requirements
The following open source software should run in your local development environment to match with the fortrabbit platform:
- Apache or NGNIX β a web server
- MySQL - database
- PHP - server side scripting language
- Git - version control - see git
- Composer - dependency manager for PHP - see composer intro
- Node.js and NPM (or similar) - frontend build processes
There are various ways to set up your local development stack, depending on your skills, needs, and operating system (Windows, macOS, or Linux). Choose the approach that best suits you.
Luckily with Composer driven PHP development it's usually enough to roughly match the remote environment. Specifically major and minor PHP versions should be kept im sync.
# Local development with virtualization
Utilizing containers allows replication of local setup across a team. Having everything stashed into a virtual machine very much nullifies any interference with the local host system. It keeps things clean. A project with a containerized local development environment can also be frozen to the software specific versions used at that time. Modern container technology is lightweight and fast and usually headless.
# DDEV
We can not recommend DDEV enough. It is an abstraction layer on top of Docker to simplify local PHP development. It's rooted in the Drupal world but is also popular with Craft CMS, Symfony, Laravel and WordPress. DDEV is sponsorware, use it for free to use, donations welcome. It's a command line tool and has many nice features and even plugins.
# Laravel Herd
Laravel Herd provides a streamlined local development environment specifically optimized for PHP applications on macOS and Windows. It bundles NGNIX, DnsMasq and some other magic to an easy to use statusbar app. For using MySQL the Pro upgrade must be bought.
# Laravel Sail
Laravel Sail is another option from Laravel eco system. As DDEV, ist a command-line interface to control Docker images.
# Docker
It's also not uncommon to directly setup a local development with Docker. Direct Docker implementation offers maximum flexibility and control. This approach requires more configuration but provides complete customization of the stack.
# Desktop virtualization
This is the old school way. Example VM applications are: VirtualBox(free by Oracle) or VMware(paid). VirtualBox controlled by Vagrant helps when setting up reproducible development environments. Homestead, which builds upon Vagrant is still popular with Laravel.
# Local development on the host
Run a web server and PHP directly on your laptop. This is often quick and lightweight to get up and running. Your options:
# Laravel Valet
This is an easy-to-use local solution not only for Laravel developers on macOS. It's a command line interface, so you install it with the Terminal. It's best installed with Homebrew and it requires Composer. The setup is easy and it aligns with best practices of modern development. It bundles NGNIX, DnsMasq and some other magic to an easy to use CLI.
- laravel.com/docs/valet
- phpmon.app - a UI for Valet
# Other options
Classical GUIs These solution stacks are easy to handle through a graphical interface and they interfere with the rest of your system as little as possible. The most commonly used here are MAMP (free and paid version) and XAAMP. Please mind that those don't include Git and Composer.
Manual setup Install and manage a web server to run your laptop. Specifically for lightweight applications, such as Kirby CMS, which does not need a database, installing the PHP runtime might be sufficient.
Found a tpyo?Edit