Skip to content

Work inside the PHP container

Work inside the PHP container

Use the PHP container as your project shell. It has the same mounted project files, the same service hostnames, and the toolchain expected by Devilbox workflows.

Enter PHP

From the Devilbox repository root:

Terminal window
./dvl.sh up php
./dvl.sh shell

./dvl.sh shell [php-version] opens an interactive shell as the devilbox user. It auto-detects .devilbox.yaml from the current project path when possible.

Examples:

Terminal window
./dvl.sh shell
./dvl.sh shell php82
./dvl.sh shell php84

Run one command without entering

Use exec for short tasks:

Terminal window
./dvl.sh exec "php -v"
./dvl.sh exec "composer --version"

Dedicated wrappers are better for common project commands:

Terminal window
./dvl.sh composer install
./dvl.sh magento cache:clean
./dvl.sh magerun cache:status

Work in a project

Projects live under data/www on the host and /shared/httpd in PHP.

Terminal window
cd data/www/my-project
../../../dvl.sh shell

Inside the container:

Terminal window
cd /shared/httpd/my-project
composer install
npm install
npm run build

If you use the global installer symlink, the host command is shorter:

Terminal window
cd data/www/my-project
dvl shell

Magento workflow

For Magento projects, prefer the DVL wrappers from the host:

Terminal window
./dvl.sh composer install
./dvl.sh magento setup:upgrade
./dvl.sh magento cache:clean
./dvl.sh magento indexer:reindex

Inside the PHP shell, direct commands also work:

Terminal window
php bin/magento cache:clean
php bin/magento setup:di:compile
composer require vendor/package

Node workflow

Use the PHP container when your selected PHP image contains the required Node tooling:

Terminal window
npm install
npm run dev
npm run build

For long-running Vite, Next.js, or frontend dev servers, bind them to all interfaces so the host can reach them:

Terminal window
npm run dev -- --host 0.0.0.0

Then open the exposed host port configured for that project or stack.

User and permissions

The shell runs as devilbox, mapped to NEW_UID and NEW_GID from .env. Files created in the container should be editable on the host.

Check the mapping:

Terminal window
id
touch /shared/httpd/permission-check.txt
exit
ls -l data/www/permission-check.txt
rm data/www/permission-check.txt

If ownership is wrong, update .env:

NEW_UID=501
NEW_GID=20

Then recreate containers:

Terminal window
./dvl.sh down
./dvl.sh up

Service hostnames

Use service names from inside PHP:

ServiceHostnameTypical port
HTTPDhttpd80 / 443
MySQL/MariaDBmysql3306
Redisredis6379
OpenSearchopensearch9200
DNSbind53

Example database check:

Terminal window
mysql -h mysql -u root -p

Become root only when needed

The devilbox user can use passwordless sudo in the PHP image:

Terminal window
sudo apt update
sudo apt install -y nmap

Leave the container

Exit the shell:

Terminal window
exit

Stop the stack when finished:

Terminal window
./dvl.sh down