Code Monkey home page Code Monkey logo

phpenv's Introduction

PHPEnv

Version 1.4.0 PHP Coverage 52.84% License GPL--3.0--only

A global Composer package for easily creating Docker containers for local PHP development. Allows you to set up containers on a project by project basis.


Easily create Docker containers configured for development with Laravel, Symfony or plain vanilla PHP, with the following services:

  • Nginx
  • MySQL 8
  • PHP 8.3 including OpCache and XDebug
  • Redis

Installation


Pre-requisites:

You will need the following installed before you can make use of PHPEnv:

  • Composer
  • Docker Desktop

Then download and install PHPEnv globally:

composer global require dannyxcii/phpenv

To confirm that the package is installed successfully, run the phpenv command which will list the help text.

Usage


To run phpenv commands, ensure Docker Engine is running.

Build

To build a new container for a project you can run the following command:

phpenv build project-name full/path/to/project-root
phpenv build portfolio-site /c/Development/Websites/portfolio-site

This will build a new container for your project and serve files from your-project-root/public at http://localhost:<port> with the port being a randomly assigned port. Once built your containers ports are static and will not change upon restarting your container.

Your database container name and IP can be found in Docker Desktop or by running the relevant Docker commands. Root credentials are root:docker.


Other Commands:

  • phpenv help
    • Displays a list of available commands.
  • phpenv show
    • Display a list of environments created with phpenv.
  • phpenv start <name>
    • Starts a container by saved name. Pass the name you used when running the build command.
  • phpenv stop <name>
    • Stops a running container by saved name.
  • phpenv destroy <name>
    • Destroys a container by saved name.
  • phpenv attach <name>
    • Attach to the bash terminal within your projects container.

phpenv's People

Contributors

danielwinning avatar

Stargazers

 avatar

Watchers

 avatar

phpenv's Issues

Add support for .phpenv files

To allow for fine tuning of environments support should be added for .phpenv files within projects.

The file could look something like this:

PHP_VERSION 8.3
NODE_VERSION 20
...

Declare port 9003

Some commands inside the container display the error:

Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port).

PHP container should declare port 9003.

Add NPM/NPX to the container

PHP container does not include npm and npx commands by default.

Best to use defined versions so environments are consistent.

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.