Web development environment setup for UNIX.
- Find the PHP path inside the docker container
docker exec -it docker.php bash
which php
- Create a wrapper script
docker-php
to run PHP commands via docker
# for example: the current PATH is /usr/local/bin
sudo nano /usr/local/bin/docker-php
- Add the following code
#!/bin/bash
docker compose exec docker.php php "$@"
- Make the script executable
sudo chmod +x /usr/local/bin/docker-php
- Use the new script to run PHP commands in your machine
docker-php -v
docker-php -r 'echo "Hello from Docker PHP!\n";'