Coder Social home page Coder Social logo

phpdock's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.