How to Format PHP Code Automatically: PHP-CS-Fixer, PHPCBF and Pint

Online PHP beautifiers were handy in 2011. Today a command-line fixer formats a whole project to a standard in seconds, and your editor can run it on save.

Online PHP beautifiers were handy in 2011. Today a command-line fixer formats a whole project to a standard in seconds, and your editor can run it on save.

The old php5 handler lines no longer apply, but .htaccess can still pick the PHP version on many hosts. Here is the current cPanel format, safer panel options and how to verify the result.

Large uploads fail because of several limits, not one. Here is which PHP settings to raise, where to set them on your type of hosting, and the web server and CDN limits to check next.

isset($_SERVER["HTTPS"]) is not quite enough. Here is a check that also handles IIS, non-standard ports and sites behind Cloudflare or a load balancer.

Google Product Search became Google Merchant Center, but the XML feed idea is the same. This builds a valid feed from MySQL with PHP, streaming rows so large catalogs work.

A cast handles simple objects, json_encode and json_decode handle nested ones, and WordPress has its own helpers. Here is when to use each, and the private property gotcha.

If FCKeditor says an image uploaded but nothing appears, check paths and permissions. Then plan to replace it, because its file connector is a common way sites get hacked.
The old trick of posting your cPanel password to a backup form no longer works. Today you call cPanel's UAPI with an API token, from a cron job or PHP, and send the archive off the server.
PHP's mail() fails on XAMPP and WAMP out of the box. The quickest fix for development is a local mail catcher like Mailpit; for real delivery, use PHPMailer over authenticated SMTP.