Skip to content

Instantly share code, notes, and snippets.

@assada
Last active June 20, 2023 11:01
Show Gist options
  • Save assada/978b4b86730098149140e3aef7662f16 to your computer and use it in GitHub Desktop.
Save assada/978b4b86730098149140e3aef7662f16 to your computer and use it in GitHub Desktop.
Fake PHP\Composer binares
docker run --net=host --rm --interactive --tty -v $(pwd):/app --user $(id -u):$(id -g) -v ~/.ssh:/home/user/.ssh -w /app composer:1 composer "$@"
  1. nano php
  2. paste and save php string
  3. nano composer
  4. paste and save composer string
  5. chmod a+x ./php
  6. chomd a+x ./composer
  7. sudo mv ./php /usr/bin/php (/usr/local/bin/php ?)
  8. sudo mv ./composer /usr/bin/composer (/usr/local/bin/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 -it --rm --interactive --tty -v $(pwd):/app --user $(id -u):$(id -g) -v ~/.ssh:/home/user/.ssh -w /app composer composer"

BE AWARE! composer docker image uses the latest 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)

docker run --net=host --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:8.1-cli php "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment