in .bashrc
on in .zshrc
insert:
function php() {
docker run --rm --interactive --tty \
--user $(id -u):$(id -g) \
--volume "$(pwd)":/app \
-w /app \
php:8.2-cli-alpine php $@
}
then in the terminal you can user php as normal command line:
php -v
example:
» php -v
PHP 8.2.4 (cli) (built: Mar 16 2023 22:00:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.4, Copyright (c) Zend Technologies
function composer() {
docker run --rm --interactive --tty \
--volume "$PWD":/app \
--user $(id -u):$(id -g) \
composer composer $@
}
then in the terminal you can user php as normal command line:
composer --version