NightFox

NightFox

PHP and MySQL Command Reference

The PHP and MySQL commands I keep looking up, all in one place so I can stop searching for them. Local dev, debugging, Composer, PHP-FPM, MySQL, backups, and a little Git.

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 the 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

Looking at schemas and queries

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

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

Handy file searches

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

Last Modified: October 12, 2026, 11:46 am