Local development

Why and how to set a local PHP development environment.

Problem

fortrabbit Apps are made for production (live) or staging (review). They are not well suited for online development. The deployment is fast but still takes too long when developing rapid changing aspects of your App. Also, it is never a good idea to have your live application display errors and debugging informations.

Solution

Set up a local PHP development environment so that your Apps can run on your local machine as well as remote on the fortrabbit. Our workflow is to run every live App locally under {{app-name}}.dev, while {{app-name}}.frb.io runs on fortrabbit, of course. To make this happen you need to have some open source software running:

Setup

There are multiple ways to get your local development stack up and running: You can use a prepared solution stack, bundled up and controlled by a user friendly GUI (best for beginners), you can set up what you need manually or you can box everything neatly into a virtual machine.

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:

  • XAAMP GUI for Windows, Mac OS, Linux
  • MAMP GUI for Mac OS and Windows

Those don't include Git and Composer.

Manual setup

Well, it's all manual so you should attempt it only if you know what you are doing. To get you started, we looked up some helpful guides:

Virtualization

Utilizing virtualization for development allows you better replication of your local setup across your team. Also having a everything stashed into a virtual machine very much nullifies any interference with your local host system. In a sentence: It keeps things clean.

There are two primary virtualization approaches for development: Desktop virtualization, for example VirtualBox or VMware or container virtualization, which means primarily Docker these days. There are a lot of fundamental difference between both approaches, but when considering development it boils down to: Desktop virtualization is easier to setup but eats up more resources - container virtualization is harder to setup, but once done easier to use and is very economical in terms of resource usage.

Many developers today use VirtualBox controlled by Vagrant, which helps a lot when setting up reproducible development environments from scratch - or rather from config file. Many Laravel developers use Homestead, which builds upon Vagrant and simplifies Laravel development even further.

Have a look at Docker for Mac or … for Windows, it's on the rise.

Other solutions

The Laravel guys came up with a easy-to-use solution just for Laravel developers on Mac OS called Valet. If you fit that description then it's definitely worth looking into.

Considerations

What else you need to think about when setting up your local development environment.

Composer

You will most likely need Composer, as it is the one and only PHP dependency manager (besides PEAR, but who uses that anymore?):

Environment detection

Our code examples in the install guides always include checks to detect if the App is running locally or on fortrabbit. You should consider this when developing your code - or rather setting up your configuration. For example: MySQL will need different credentials locally then on fortrabbit.

Multi-staging

You might want to have a dedicated remote testing environment with pubic access? Head over to our advanced multi-staging article.

Apache instead of NginX

Some might prefer a NginX web-server over Apache as it is easier to configure. Mind that fortrabbit is using Apache, some features might not be compatible. You will find .htaccess examples in these articles which only work with Apache.

Virtual hosts

You might set up multiple vhosts - not just localhost or 127.0.0.1 - to serve multiple websites from one machine.

Further readings

Search help pages

Need individual help?

Get support › Learn about Company plans ›

Looking for an old article?

See the full list of articles ›

Found an error?

Contribute on GitHub ›