https://github.com/InteractionDesignFoundation/coding-standard
PHPCS coding-standard for Laravel applications and packages
https://github.com/InteractionDesignFoundation/coding-standard
coding-style laravel phpcs-standard
Last synced: 15 days ago
JSON representation
PHPCS coding-standard for Laravel applications and packages
- Host: GitHub
- URL: https://github.com/InteractionDesignFoundation/coding-standard
- Owner: InteractionDesignFoundation
- Created: 2023-04-14T13:55:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-11T22:36:16.000Z (3 months ago)
- Last Synced: 2026-01-11T18:27:26.160Z (about 2 months ago)
- Topics: coding-style, laravel, phpcs-standard
- Language: PHP
- Homepage:
- Size: 143 KB
- Stars: 6
- Watchers: 8
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/InteractionDesignFoundation/coding-standard/actions/workflows/test.yml)
[](https://github.com/InteractionDesignFoundation/coding-standard/actions/workflows/psalm.yml)
[](https://shepherd.dev/github/InteractionDesignFoundation/coding-standard)
[](https://shepherd.dev/github/InteractionDesignFoundation/coding-standard)
# IxDF Coding Standard for Laravel
An opinionated ruleset focused on strict types.
Suitable for both applications and packages.
## Installation
1. Install the package via composer by running:
```shell
composer require --dev interaction-design-foundation/coding-standard
```
2. Add composer scripts into your `composer.json`:
```json
"scripts": {
"cs:check": "phpcs -p -s --colors --report-full --report-summary",
"cs:fix": "phpcbf -p --colors"
}
```
3. Create file `phpcs.xml` on the base path of your repository with content
```xml
app
config
database
lang
routes
tests
```
## Usage
- To run checks only:
```shell
composer cs:check
```
- To automatically fix many CS issues:
```shell
composer cs:fix
```
## Ignoring parts of a File
Disable parts of a file:
```php
$xmlPackage = new XMLPackage;
// phpcs:disable
$xmlPackage['error_code'] = get_default_error_code_value();
$xmlPackage->send();
// phpcs:enable
```
Disable a specific rule:
```php
// phpcs:disable Generic.Commenting.Todo.Found
$xmlPackage = new XMLPackage;
$xmlPackage['error_code'] = get_default_error_code_value();
// TODO: Add an error message here.
$xmlPackage->send();
// phpcs:enable
```
Ignore a specific violation:
```php
$xmlPackage = new XMLPackage;
$xmlPackage['error_code'] = get_default_error_code_value();
// phpcs:ignore Generic.Commenting.Todo.Found
// TODO: Add an error message here.
$xmlPackage->send();
```
## Development
### Versioning
> **New rules or Sniffs may not be introduced in minor or bugfix releases and should always be based on the develop
branch and queued for the next major release, unless considered a bugfix for existing rules.**
## Reference
Rules can be added, excluded or tweaked locally, depending on your preferences.
More information on how to do this can be found here:
- [Coding Standard Tutorial](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial)
- [Configuration Options](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options)
- [Selectively Applying Rules](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset#selectively-applying-rules)
- [Customisable Sniff Properties](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties)
- Other coding standards (inspiring us):
- [Slevomat coding standard](https://github.com/slevomat/coding-standard)
- [Doctrine coding standard](https://github.com/doctrine/coding-standard)
- [Laminas coding standard](https://github.com/laminas/laminas-coding-standard)