Skip to content

go-to-the-next-level-dev/php-docker-bootstrap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP and PHPUnit Bootstrap with docker

Goal

  • Simplify the setup of a PHP environment
  • Use at the same time different versions of PHP

Content

  • PHP 7.1.2
  • PHPUnit 5.7 (Compatible with PHP 5.6, PHP 7.0, and PHP 7.1)
  • First PHPUnit test
  • Phpstorm settings

0. Prerequisites

1. Prepare the setup

1.1. Build the image

$ make build

1.2. Install the composer dependencies

$ make composer-install

2. Run the tests

2.1. From command line

make test

2.2. From PHPStorm

2.2.1. Configure docker

Follow the instructions according your operating system

In linux is:

Click: Build, execution, deployment | Docker
Click: +
Write: API Url: unix:///var/run/docker.sock
Write: Docker compose executable: /usr/local/bin/docker-compose 

2.2.2. Configure Interpreter

Click: Languages & Frameworks | PHP 
Click: CLI Interpreter | ...
Click: + | Remote
Write: Name: Docker PHP 7.1.2
Select: Remote | Docker
Write: Image name: my-php
Write: General executanble: php

2.2.3. Configure PHPUnit

Click: Languages & Frameworks | PHP | PHPUnit 
Click: + | By Remote Interpreter
Select: Cli interpreter: Docker PHP 7.1.2
Click: PHP Unit library: Use composer autoloader
Write: Path to script: vendor/autoloader.php

2.2.4. Run

Right click: tests folder | Run 'tests'

3. Change the PHP Version

If you want to use other version of PHP it's as easy as follow the steps:

  • Edit Dockerfile
  • Select a valid version of PHP from Docker Hub
  • Follow the "Prepare setup" steps
  • Validate the composer.json to verify all the requisites are satisfied.

About

Docker setup with php, phpunit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 52.8%
  • Makefile 47.2%