1.1.9 • Published 3 years ago

docker-php-development v1.1.9

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Docker PHP Development

Docker running Nginx, PHP-FPM, MariaDB and PHPMyAdmin.

A simple package that makes it easy to start a new local development environment.

Install

To install the docker-php-development package use npm or yarn.

NPM:

npm install -g docker-php-development

Yarn:

yarn global add docker-php-development

Note: The package has to be installed globally

Basic Usage

After successfully installing docker-php-development you can use the dock command.

Use dock -h or dock --help to see all possible commands.

Output:

-i, --init        Install the dock into your project
-s, --start       Start the dock
-e, --stop        Stop the dock
-q, --stopall     Stop all running docks
-a, --showall     Show all existing docks
-f, --foreground  Start dock on foreground
-d, --dbdump      Dumps the database into a database.sql file in projectroot
-r, --dbrestore   Retores the database dump in projectroot folder
-l, --logs        Show logs
-h, --help        output usage information

Init the dock:

To start a local development environment use dock -i in your project root.

This will add a new folder into your project, ./docker this folder will hold the configuration files for your dock.

The init option will also ask you to name your containers and assign port numbers to them.

Note: Make sure the container names are unique otherwise docker won't be able to start them.

init command example

Start the dock:

To start the dock use dock -s or dock --start this will create the docker containers.

Go to localhost:YourWebserverPort to view the webserver, the index.html or index.php file in your projectroot will be displayed.

Go to localhost:YourPhpMyAdminPort to view the database, login with root/root or with devdb/devdb.

Note: YourWebserverPort/YourPhpMyAdminPort ports are set in the init process, if you forgot what the set ports are or want to change them go to the docker-compose.yml file in the docker folder inside your projectroot.

The database user devdb and database wordpress is created on the first dock --start this username, password & databasename can also be changed in the docker-compose.yml file in the docker folder inside your projectroot.

Stop the dock:

To stop the dock use dock -e or dock --stop this will stop the docker containers.

Output logs to the shell:

To output logs use dock -l or dock --logs this will continuesly output the logs from the containers.

Note: This can also be achieved with the dock --foreground command, this will start the containers and directly output the logs.

Dump DB:

To dump the database use dock -d or dock --dbdump this will dump the database to the root of your project.

Note: This database.sql file won't automatically get restored on a dock --start, when the containers are stopped they still contain all your data so we won't need to restore the database, but if somehow your container gets destroyed it's nice to have the latest database file.

This can also be usefull for cloning your project, to restore the database simply run dock -r or dock --dbrestore.

Additional info

The docker folder in your project root holds all the files to edit the configuration, to change php.ini values simply go to the ./docker/php.ini file and add any overwrite you need.

The ./docker/Dockerfile contains the PHP-FPM config, it'll use the original latest php:7-fpm image and install some additional packages using apt-get, docker-php-ext & pecl.

The ./docker/nginx.conf contains the nginx config, the basic configuration is probably enough for most PHP projects but you can change this anyway you'd like.

The ./docker/docker-compose.yml contains the docker-compose config, on dock --start this file gets read and will be used to start the containers. Edit this file to change your ports, database_username or database_password


In Projects where you need to use the Database use keyword "database" as the hostname, docker will use the name to lookup the ip:port.

hostname example

1.1.9

3 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.51

5 years ago

1.1.5

6 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

0.0.5

7 years ago

0.0.11

7 years ago

1.0.4

7 years ago

1.0.33

7 years ago

1.0.32

7 years ago

1.0.31

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

0.0.1

7 years ago

1.0.0

7 years ago