Skip to content

marriosdev/phpctl

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

phpctl logo

phpctl phpctl ci badge

🐳 A Docker-based development environment for PHP 🐘

Heavily inspired by opencodeco/hfctl.

Introduction

Frictionless PHP Development! Seamlessly run and switch between different versions of PHP, with different installed extensions, thanks to the power of containers. Take the advantage of goodie commands like phpctl create to start a new project, phpctl repl to start a REPL, phpclt init to initialize a new configuration file and a lot more.

Getting started

Tip

Pro-tip: use it with stack to spin up infrastructure components like MySQL, Redis, RabbitMQ etc.

Requirements

  • Git
  • Docker

Install

sh <(wget -qO- https://raw.githubusercontent.com/opencodeco/phpctl/main/installer.sh)

Update

You can re-run the installer or use the self-update command:

phpctl self-update

Usage

Then you can use phpctl or pctl with a subcommand:

phpctl <command> [arguments]

For example

phpctl php -m # To show built-in modules

Or

phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the container

Command list

Developing

Command Description
php Runs PHP commands (phpctl php -v or phpctl php -m).
composer Runs Composer commands (phpctl composer install or pctl composer validate).
server [port] [directory] Runs PHP's built-in web-server (default port is 80 and default directory is current .).

Useful

Command Description
phpunit Runs PHPUnit.
sh [commands] Starts an interactive Shell session or runs sh commands.
repl Starts a PHP REPL session (powered by PsySH).
php-cs-fixer Runs PHP-CS-Fixer.
phpstan Runs PHPStan.
infection Runs Infection.
pest Runs Pest.
pint Runs Pint.
box Runs Box.
bundle Bundles a project into an image and ships it as a single binary file.

Scaffolders

Command Description
create [framework] [dir] Creates a new project using the given framework (or package).
init [skeleton] Initializes a skeleton configuration.

Skeletons

  • phpunit
  • php-cs-fixer
  • phpstan
  • infection
  • box

Helpers

Command Description
help or man Displays a help message.
self-update Updates phpctl iself.
doctor Inspects the current PHP_VERSION and PHPCTL_IMAGE.
build Builds the current Dockerfile (useful for custom images).
images Shows local phpctl images.

The .phpctlrc file

You can also add a .phpctlrc file at project's root directory with some overrides like:

Environment variables

Variable Description
PHP_VERSION Values can be 82 and 83
PHPCTL_IMAGE Use to name your own custom image

For example:

PHP_VERSION=83

Docker behaviour

Run options

You can also provide any additional Docker run arguments using the args variable.

For example, suppose you want to bind the 9501 port from the running phpctl container to your host, you can add the following to your .phpctlrc file:

args=(-p 9501:9501)

Build options

You can also provide build options to the build command using the build variable:

build=(--build-arg APP_ENV=dev --label phprocks)

Podman

You can use Podman instead of Docker by setting the PHPCTL_RUNTIME variable to podman in your environment variables or at .phpctlrc file.

PHPCTL_RUNTIME=podman phpctl php -v

Modules

For the default Docker image we have the following modules installed (click to expand).
[PHP Modules] Core ctype curl date dom fileinfo filter hash iconv igbinary json libxml mbstring mongodb msgpack mysqlnd openssl pcntl pcov pcre PDO pdo_mysql Phar posix random rdkafka readline redis Reflection session SimpleXML sockets SPL standard swoole tokenizer xml xmlreader xmlwriter zlib 

You can always use your custom image with the PHPCTL_IMAGE variable, but feel free to ask for more essential extensions in the issues.

Why it exists?

Tip

After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions, I came out with phpctl to use the power of containers to seamlessly run PHP 🐘 for developement environments.

Contributing

Click here to read the contributing guidelines.

About

🐳 It is a Docker (containers) based development environment for PHP 🐘

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 92.0%
  • PHP 4.6%
  • Dockerfile 2.0%
  • Makefile 1.4%