Go to file
assada 66c4e8dc8b
Initial commit
2023-07-13 17:54:22 +03:00
php Initial commit 2023-07-13 17:54:22 +03:00
Makefile Initial commit 2023-07-13 17:54:22 +03:00
README.md Initial commit 2023-07-13 17:54:22 +03:00
composer.fish Initial commit 2023-07-13 17:54:22 +03:00
php.fish Initial commit 2023-07-13 17:54:22 +03:00

README.md

Docker based PHP and composer CLI

Php cli and composer in docker container for cli usage. With XDebug, git, strace, pdo and redis extensions inside.

Now you don't have to install php and composer on your local machine(e.g sudo apt install php). Just use docker container instead!

With this you can run smth like composer install && php artisan serve and debug your application with XDebug in your IDE.

How to setup

  1. make build
  2. nano php
  3. paste and save php string
  4. nano composer
  5. paste and save composer string
  6. chmod a+x ./php
  7. chomd a+x ./composer
  8. sudo mv ./php /usr/bin/php (/usr/local/bin/php ?)
  9. sudo mv ./composer /usr/bin/composer (/usr/local/bin/composer ?)

PHP String (for debian based distros)

docker run -e PHP_IDE_CONFIG="serverName=host.docker.internal" --add-host=host.docker.internal:host-gateway --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --net=host -it --rm -v "$PWD":/var/www -w /var/www assada/php:8.2-cli-alpine php

Composer String (for debian based distros)

docker run --interactive --tty --add-host=host.docker.internal:host-gateway --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --net=host -it --rm -v ~/.ssh:/root/.ssh -v composertmp:/tmp -v "$PWD":/var/www -w /var/www assada/php:8.2-cli-alpine composer

OR! You can create just simple alias for your shell instead fake binary creation

Fish shell example:

cat ~/.config/fish/functions/composer.fish
alias composer="docker run --interactive --tty --add-host=host.docker.internal:host-gateway --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --net=host -it --rm -v ~/.ssh:/root/.ssh -v composertmp:/tmp -v "$PWD":/var/www -w /var/www assada/php:8.2-cli-alpine composer"

BE AWARE! composer docker image uses the latest(8.2) php version. So, if u want to use older php you must create personal image with preferred php version (e.g 7.4). Or... just ignore platform reqs (e.g composer install --ignore-platform-reqs)