PHP and MySQL Command Reference

A compact reference for common local-development, debugging, Composer, PHP-FPM, MySQL, and deployment commands.

PHP CLI

php -v
php -m
php --ini
php -i | less
php -l path/to/file.php
php -S 127.0.0.1:8080 -t public
php -d display_errors=1 -d error_reporting=E_ALL script.php

Composer

composer install
composer update
composer outdated
composer audit
composer validate
composer dump-autoload -o
composer run test
composer show --tree

PHP-FPM and Web Server

systemctl status php-fpm
journalctl -u php-fpm -f
nginx -t
apachectl configtest
curl -I https://example.test/
curl -sS -D - https://example.test/api/health

MySQL Client

mysql --host=127.0.0.1 --user=app_admin --password
mysql --database=customer_portal --execute="SHOW TABLES"
mysqladmin processlist
mysqladmin status

Schema and Query Inspection

SHOW CREATE TABLE customers\G
SHOW INDEX FROM customers;
EXPLAIN ANALYZE SELECT * FROM customers WHERE status = 'active';
SHOW FULL PROCESSLIST;
SHOW ENGINE INNODB STATUS\G

Backup and Restore

mysqldump --single-transaction --routines --triggers --events \
  --databases customer_portal | gzip > customer_portal.sql.gz

gunzip -c customer_portal.sql.gz | mysql --user=restore_operator --password

Git Workflow

git status
git switch -c feature/customer-search
git diff --check
git add -p
git commit
git log --oneline --decorate -20

Useful File Searches

find . -name '*.php' -print0 | xargs -0 -n1 php -l
rg "TODO|FIXME" src tests
rg "mysql_query|each\(|create_function" . --glob '*.php'