What tools or resources can be used to automatically format PHP code for better presentation?

When working with PHP code, it is important to maintain a clean and consistent formatting for better readability and maintainability. One way to automatically format PHP code is by using tools such as PHP_CodeSniffer or PHP-CS-Fixer. These tools can help standardize the code style, indentations, and spacing according to predefined rules or coding standards.

// Example of using PHP_CodeSniffer to automatically format PHP code
// Install PHP_CodeSniffer using Composer
// composer require squizlabs/php_codesniffer --dev

// Run PHP_CodeSniffer to fix coding standards
// vendor/bin/phpcs --standard=PSR2 path/to/your/php/files

// Example of using PHP-CS-Fixer to automatically format PHP code
// Install PHP-CS-Fixer using Composer
// composer require friendsofphp/php-cs-fixer --dev

// Run PHP-CS-Fixer to fix coding standards
// vendor/bin/php-cs-fixer fix path/to/your/php/files