I'm thinking about changing from sublime text 3 to atom and i want to set the identation standard for codeigniter 4, PSR12.
I've installed globaly via composer the following packages:
- PHP_CodeSniffer
- Codeigniter4-Standard
- PHP-CS-Fixer
Using the following commands:
composer global require "squizlabs/php_codesniffer=*"
composer global require codeigniter4/codeigniter4-standard
composer global require friendsofphp/php-cs-fixer
And in the end this:
export PATH="$PATH:$HOME/.composer/vendor/bin"
I've also noticed that my executables are not on the /home/user/.config/composer folder but on the /home/user/.composer folder.
Maybe i did something wrong on this...
On atom, I've installed atom-beautify and php-cs-fixer.
On the atom-beautify my confis are these ones: General settings:
- Beautify entire file on save: checked
- Show loading view: checked
Executables:
PHP-cs-Fixer -> binary/script path :
/home/{user}/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
PHPCBF -> Binary/script path:
/home/{user}/.composer/vendor/squizlabs/php_codesniffer/bin/phpcbf
PHP:
Default Beautifier: PHP-cs-Fixer
Beautify on save: checked
Allow risky rules: no
PHP-CS-Fixer Version: 2
Rules: @PSR12
PHPCBF Standard:
/home/{user}/.composer/vendor/codeigniter4/codeigniter4-standard/CodeIgniter4
And finally my atom-beaufity config.cson:
"*":
"atom-beautify":
executables:
php: {}
"php-cs-fixer":
path: "/home/emerson/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"
phpcbf:
path: "/home/emerson/.composer/vendor/squizlabs/php_codesniffer/bin/phpcbf"
general:
_analyticsUserId: "{private-data}"
php:
beautify_on_save: true
rules: "@PSR12"
standard: "/home/emerson/.composer/vendor/codeigniter4/codeigniter4-standard/CodeIgniter4"
core:
telemetryConsent: "limited"
editor:
showIndentGuide: true
"exception-reporting":
userId: "{private-data}"
"php-cs-fixer":
executablePath: "/home/emerson/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"
phpExecutablePath: "/usr/bin/php"
BTW: Also i would like to ask which plugins do you guys use for web development with php.
Many thanks!
EDIT:
I've managed to set the PSR12 and i will post my new config.cson bellow:
"*":
"atom-beautify":
executables:
php: {}
"php-cs-fixer":
path: "/home/emerson/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"
phpcbf:
path: "/home/emerson/.composer/vendor/squizlabs/php_codesniffer/bin/phpcbf"
general:
_analyticsUserId: "31b3a718-ab3d-4ec3-96e3-6f5d1c2e2c6b"
php:
beautify_on_save: true
standard: "PSR12"
core:
telemetryConsent: "limited"
editor:
fontSize: 13
showIndentGuide: true
"exception-reporting":
userId: "6ecc9e46-806b-4e85-9867-e66075d62870"
"php-cs-fixer":
executablePath: "/home/emerson/.composer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer"
phpExecutablePath: "/usr/bin/php"
The problem now is that atom doesn't "beautify" the php code on the views, only on models and controllers, even tought the view file is also .php
Just set the PHPCBF as the default beautifier and use the following configs (you have to change the executable paths to yours):