phpdock is a php's version manager, powered with Docker, using principally the oficial php repository in Docker Hub.
phpdock is inspired in rbenv, goenv and pyenv
- Clone phpdock into ~/.phpdock
$ git clone [email protected]:lucasdc6/phpdock.git ~/.phpdock
- Add the envoiroment variable PHPDOCKPATH and the directory $PHPDOCKPATH/bin to
$PATH
$ echo 'export PHPDOCKPATH=$HOME/.phpdock' >> ~/.bash_profile
$ echo 'export PATH="$HOME/.phpdock/bin:$PATH"' >> ~/.bash_profile
- Add the eval sentence to the bashrc
$ echo 'eval "$(phpdock init -)' >> ~/.bash_profile
Ubuntu desktop note: Modify your ~/.bashrc
instead of ~/.bash_profile
Zsh note: Modify ~/.zshrc
- Restart your shell so that PATH changes take effect.
The script phpdock
is intended to facilitate the use of the scripts
php
and php-server
(See bin directory)
Availables scripts commands:
- Set a global php version (shell restart is needed)
- Set a local php version (shell restart isn't needed)
- Install docker php images (and php with apache!!)
- List installed versions
- List availables versions on docker repositories
Manage availables repositories:
- List repositories
- Add repository
- Delete repository
The availables repositories is stored in a file in etc
directory
Repositories file use complete docker repositories name.
Don't delete the repositories file!
All the repositories added, need docker images with a specific tag format.
Tag format:
All the tags need one of the following words:
- cli: To php images (used by
php
script) - apache: To php with apache images (user by
php-server
script)
The format is taken from the php oficial repository (see oficial php repository)
Add a repository
$ phpdock repositories --add <COMPLETE_REPOSITORY_NAME>
Eg: Add the oficial php repository (added by default)
$ phpdock repositories --add php
The script doesn't install php binaries!
The script pull docker images and reference those images via files and
envoiroment varialbes, used by the scripts php
and php-server
Variable | Description |
---|---|
PHP_CLI_DOCKER_IMAGE |
Specify a docker image to php script |
PHP_SERVER_DOCKER_IMAGE |
Specify a docker image to php-server script |
PHPDOCK_DEBUG |
Enable debug mode |
PHPDOCKPATH |
Root path to repository |
- File modified by the command
phpdock global <version>
- Stored at
$PHPDOCKPATH/etc/php-version
and$PHPDOCKPATH/etc/apache-version
- Low precedence
- File modified by the command
phpdock local <version>
- Stored in the command's context execution
- Medium precedence
- Via envoiroment variables modified by the command
phpdock shell <version>
- High precedence
Add a new php version:
-
Firts, search the complete docker image name (repository+tag)
Show all availables docker images in known repositories:
phpdock install --list # docker image's list
-
Once identified the docker image, send it as argument to
phpdock install
Eg, we need the php 7.2.0 from oficial repositoryphpdock install php:7.2.0-cli
If you know the php version needed for the project, you can create a file named
.php-version
and put the version (only the number).
This make easiest to export the project.
Once created the file, run the follow:
phpdock install
This show you a selectable menu with all docker images that match the version specified