php | ||
composer.fish | ||
Makefile | ||
php.fish | ||
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
make build
nano php
- paste and save php string
nano composer
- paste and save composer string
chmod a+x ./php
chomd a+x ./composer
sudo mv ./php /usr/bin/php
(/usr/local/bin/php
?)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
)