Installation
composer require --dev instaclick/coding-standard
Add to your phpcs.xml or phpcs.xml.dist:
<config name="standard" value="Instaclick"/>
First Run
vendor/bin/phpcs --standard=Instaclick app/
Verify the standard applies by checking for BlankLineBeforeIfSniff violations.
Key Files
app/ and src/ directories first.phpcs.xml for custom rules or exclusions.Pre-Commit Hook
Add to .git/hooks/pre-commit:
#!/bin/sh
vendor/bin/phpcs --standard=Instaclick --warning-severity=0 $1
Fail if violations exist (exit code 1).
CI/CD Pipeline Use in GitHub Actions or GitLab CI:
- name: Run PHP_CodeSniffer
run: vendor/bin/phpcs --standard=Instaclick --warning-severity=0 --report=json app/ > phpcs.json
Parse JSON output for detailed reporting.
IDE Integration Configure PHPStorm:
InstaclickTeam Onboarding
CONTRIBUTING.md.phpcs command in Makefile for quick checks:
phpcs:
@vendor/bin/phpcs --standard=Instaclick --report=full app/
False Positives in Control Structures
BlankLineBeforeIfSniff may flag Laravel blade templates or inline if conditions.exclude in phpcs.xml:
<arg name="exclude" value="resources/views,tests/Unit/" />
Symfony/Object Calisthenics Overhead
if-else patterns.<rule ref="Instaclick">
<exclude name="ObjectCalisthenics.NoElseClauseSniff"/>
</rule>
Performance with Large Codebases
vendor/ or node_modules/ is unnecessary.--ignore to skip non-PHP files:
vendor/bin/phpcs --standard=Instaclick --ignore="*,*.blade.php,*.md" app/
Verbose Output
Use --report=full to see line numbers and context:
vendor/bin/phpcs --standard=Instaclick --report=full app/
Sniff-Specific Help List available sniffs:
vendor/bin/phpcs --standard=Instaclick --list-sniffs
Example output:
Instaclick.Formatting.BlankLineBeforeIfSniff
Instaclick.ObjectCalisthenics.NoElseClauseSniff
Customizing Rules
Override specific rules in phpcs.xml:
<rule ref="Instaclick.Formatting.BlankLineBeforeIfSniff">
<properties>
<property name="allowEmptyStatements" value="true"/>
</properties>
</rule>
Adding Custom Sniffs
Extend the standard by creating a new sniff class and referencing it in phpcs.xml:
<rule ref="Custom.MyNewSniff"/>
Combining with Other Standards Merge with PSR12 or Laravel’s standard:
<config name="standard" value="Instaclick,PSR12"/>
Autofixing Violations
Use --fix for auto-correctable issues (if supported):
vendor/bin/phpcbf --standard=Instaclick app/
Note: Not all sniffs support autofixing. Test changes in a branch first.
How can I help you explore Laravel packages today?