This application comes with a PHP Coding Standards Fixer configuration php-cs-fixer.php
Within this configuration file is the agreed upon standards for the team.
When setting up the project you should set up your IDE to automatically apply these rules to the current file you are working in on save. Common IDE configurations on how to do that are listed below.
- Set the correct php cs fixer binary in:
- Language & Frameworks -> PHP -> Quality tools
- Within phpstorm, go to:
- Settings -> Editor -> Inspections -> PHP -> Quality tools
- Make sure PHP CS Fixer validation is checked
- In the right-hand pane, after selecting this option, click the browse (
...
) button and select the php-cs-fixer.php file previously saved in your home directory - Click Apply and OK
- In PHPStorm, create a file watcher (under "Preferences->Tools")
- Uncheck all the "Advanced Options"
- Edit the following settings:
Name: PHP Style fixer
File type: PHP
Scope: Current File
Path: $ProjectFileDir$/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
Arguments: fix $FileDir$/$FileName$ --verbose --config=$ProjectFileDir$/php-cs-fixer.php
- Install PHP CS Fixer extension
- Configure Extension, in
Settings as JSON
"vscode-php-cs-fixer.config": "/{path_to_repository}/php-cs-fixer.php", "vscode-php-cs-fixer.toolPath": "/{path_to_repository}/vendor/bin/php-cs-fixer", "[php]": { "editor.defaultFormatter": "fterrag.vscode-php-cs-fixer" },
- Find
PHP CS Fixer
using Package Control: Install Package (cmd-shift-p) - Under Preferences -> Package Settings -> PHP CS Fixer -> Settings - User, configure the extension using the following JSON
{ "config": "/{path_to_repository}/php-cs-fixer.php", "on_save": true, }
This application comes with Prettier and the Prettier Blade Plugin to be used in order to set and automatically apply code formatting rules to our code-base blade files.
Example of how to run the formatter manually:
spinc prettier-lint
When setting up the project you should set up your IDE to automatically apply these rules to the current file you are working in on save. Common IDE configurations on how to do that are listed below.
You can use Prettier Plugin for JetBrains IDE.
Add extension setting blade.php
to File | Settings | Languages & Frameworks | JavaScript | Prettier | Run for files:
e.g.
{**/*,*}.{css,js,ts,jsx,tsx,blade.php}
and turn on checkbox On 'Reformat Code' action
You can use Prettier extension for VSCode to format blade within VSCode. You must install this plugin as local dependencies. see https://github.com/prettier/prettier-vscode#prettier-resolution
If you want to use formatter without Prettier, please consider using vscode-blade-formatter
This application comes with a LaraStan installed to provide static analysis (technically "code analysis" as it loads the Service Container) of the code-base.
Example of how to run the static analysis manually:
spinc larastan
Setup for automatic static analysis is per IDE and should be configured as such.
Configuration is set in the phpstan.neon.dist file. If additional local configuration is desired, you can create a phpstan.neon
file in the root of the project and it will be loaded automatically.
Example phpstan.neon
file:
includes:
- phpstan.neon.dist
parameters:
editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'
This application comes with a Laravel IDE Helper installed to provide better auto-completion for Laravel Facades and other classes.
Helper and meta files can be generated by running the following commands, and should be run after any changes to the code-base that would affect the auto-completion.
spina ide-helper:generate
spina ide-helper:meta
Additionally, a helper file and related DocBlocks are generated to provide auto-completion and static analysis for Models and their relationships. This is done by running the following command, and should be run after any changes to Models.
spina ide-helper:models -M