Skip to content

Latest commit

 

History

History
158 lines (112 loc) · 4.15 KB

README.md

File metadata and controls

158 lines (112 loc) · 4.15 KB

phpdock

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

Contents

Install

Local

  1. Clone phpdock into ~/.phpdock
$ git clone [email protected]:lucasdc6/phpdock.git ~/.phpdock
  1. 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
  1. 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

  1. Restart your shell so that PATH changes take effect.

Use

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!

Add repositories

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

Environment variables

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

Version files

Global version

  • File modified by the command phpdock global <version>
  • Stored at $PHPDOCKPATH/etc/php-version and $PHPDOCKPATH/etc/apache-version
  • Low precedence

Local version

  • File modified by the command phpdock local <version>
  • Stored in the command's context execution
  • Medium precedence

Shell version (Comming soon!)

  • Via envoiroment variables modified by the command phpdock shell <version>
  • High precedence

Install php version

Manual

Add a new php version:

  1. Firts, search the complete docker image name (repository+tag)

    Show all availables docker images in known repositories:

     phpdock install --list
     # docker image's list
  2. Once identified the docker image, send it as argument to phpdock install Eg, we need the php 7.2.0 from oficial repository

     phpdock install php:7.2.0-cli

Using .php-version file

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