Skip to content

A local Docker Environment for building PHP applications ๐Ÿ”จ

Notifications You must be signed in to change notification settings

mattdillon100/docker-dev

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

68 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

A LAMP Local Development Environment on Docker

An everyday local development environment for PHP Developers. At Pivotal Agency, we've done a buuunnnch of R&D to find the best local dev tools for our team. This is the result of our hard work. This tool has been put to its paces everyday by our team, we hope it can also help yours.


Intro ๐Ÿ‘‹

This is a set of Docker images to spin up a LAMP stack (Linux, Apache, MySQL and PHP) for developing locally. It's perfect for local development because you can very simply add new sites to specified directory and they're magically accessible as a subdomain of your chosen hostname (eg. eg. ~/Sites/info maps to http://info.localhost/).

It includes all the required dependencies for everyday PHP development with common tools like Laravel, Wordpress and Magento (1 & 2).

Specifically, it has the following tech available:

  • Debian Jessie
  • PHP 7.1.x (default) and PHP 5.6.X
  • MySQL 5.7
  • Redis 3.x
  • Memcached
  • Composer
  • NodeJS & NPM
  • Mailhog
  • Blackfire (for PHP performance testing)

We have some clever domain mapping available to allow you to run code for various platforms. Sites are accessible from the following URLs (by default it's http://<website>.localhost, however APACHE_HOSTNAME can modified in .env to point to a different hostname):


Prerequisites โš ๏ธ

  • Your machine must be MacOS, Windows 10 Pro or Linux
  • Your CPU must support virtualisation (Intel VT-x or AMD-V)
  • You must have Docker Compose installed and Docker installed & running

Installation ๐Ÿš€

# Clone the repo
git clone https://github.com/pvtl/docker-dev && cd docker-dev

# Create & update relevant config (eg. point sites to your sites directory)
cp .env.example .env

# Start the environment
docker-compose up -d

(Optional) If you're doing local development at .localhost for example, you may need to update your computer's hosts file to point each URL to 127.0.0.1. Eg.

# Open your hosts files (with admin rights)
sudo nano /etc/hosts

# Append each site you need to access - eg.
127.0.0.1 info.localhost

Updating ๐Ÿ”„

Open a terminal window, browse to this project's folder and run:

git pull                        # 1. Pull from Git
docker-compose up -d --build    # 2. Rebuild & start the new env

*This will also install the latest versions of PHP, Redis, NodeJS and NPM.


Common Commands ๐Ÿ”ฅ

Docker must be running and commands should be run within this repo's root.

Command Description
docker-compose up -d Start
docker-compose down Stop
docker exec -it web bash SSH into web container
docker exec -it db bash SSH into Database container
docker ps Show which containers are running

Connections ๐Ÿšฅ

Email

All email is sent from the application and "caught" by Mailhog. This means that the application will send the mail, just not out to a real email. This is helpful in development, so that others aren't spammed by test emails.

You can view anything which has been sent and caught via http://localhost:8025/.

MySQL

You can connect to the MySQL server running in the container using MySQL Workbench, Navicat or Sequel Pro.

Parameter Value
Connection Standard TCP/IP
Host db (from a container) OR localhost (from your computer)
Port 3306
Username root
Password dbroot (this can be changed in .env)

Redis

You can connect to the Redis server with:

Parameter Value
Host redis (from a container) OR localhost (from your computer)
Port 6379
Password ``

Memcached

You can connect to the Memcached server with:

Parameter Value
Host memcached (from a container) OR localhost (from your computer)
Port 11211

About

A local Docker Environment for building PHP applications ๐Ÿ”จ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published