GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - InteractionDesignFoundation/coding-standard: 🪷 PHPCS coding-standard for Laravel applications and packages

BranchesTags
Open more actions menu

Latest commit

 

History

129 Commits
129 Commits

Folders and files

NameName
Last commit message
Last commit date
.cache
.cache
 
 
.github/workflows
.github/workflows
 
 
IxDFCodingStandard
IxDFCodingStandard
 
 
art
art
 
 
docs
docs
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpcs.xml
phpcs.xml
 
 
phpunit.xml
phpunit.xml
 
 
psalm-baseline.xml
psalm-baseline.xml
 
 
psalm.xml
psalm.xml
 
 
rector.php
rector.php
 
 
renovate.json
renovate.json
 
 

Repository files navigation

IxDF PHP Coding Standard

Tests PHP Psalm PHP Psalm Level PHP Psalm Type Coverage Total Downloads Latest Stable Version

IxDF PHP Coding Standard

An opinionated coding standard for PHP and Laravel projects, built on PER-CS3.0. Focuses on:

  • High signal-to-noise ratio (concise but informative PHPDoc, e.g. array shapes)
  • Strict, explicit code: strict_types, strict comparisons, final by default, no magic
  • Harmony with static analysis tools (PHPStan, Psalm, Rector, etc.)
  • Auto-fixing over reporting (violations are not only reported but also fixed automatically, when possible)
  • PHP and Laravel best practices (enforced, not just suggested)

Two tools, two roles, meant to run together:

  • PHP-CS-Fixer (primary): fast auto-formatting and modernization rules.
  • PHP_CodeSniffer (supplementary): structural and semantic checks PHP-CS-Fixer cannot express (complexity, Laravel conventions, naming).

Tip

This repository is a part of the IxDF toolchain for PHP: Rector ➝ Coding Standard Fixers ➝ PHPStan + Psalm.

1. Installation

composer require --dev interaction-design-foundation/coding-standard

2. Configuration

PHP-CS-Fixer

Primary formatter.

Create .php-cs-fixer.php in your project root:

<?php declare(strict_types=1);

use IxDFCodingStandard\PhpCsFixer\Config;

// @see https://mlocati.github.io/php-cs-fixer-configurator/ for ruleOverrides options.
return Config::create(__DIR__, ruleOverrides: []);
Customization (optional) Config::create() ships a sensible default Finder and enables parallel runs, risky rules, and caching. You can customize it by using your Finder instance and by overriding individual rules:
use PhpCsFixer\Finder;

$finder = Finder::create()->in(__DIR__)->name('*.php');

// Override individual rules, your own Finder and use your cache path
return Config::create(__DIR__, finder: $finder, ruleOverrides: [
    'final_class' => true,
])->setCacheFile('./.cache/.php-cs-fixer.cache');

Need only the rule array (e.g. to compose your own config)?

$rules = \IxDFCodingStandard\PhpCsFixer\Rules::get();

Run it:

vendor/bin/php-cs-fixer fix

PHP_CodeSniffer

Supplementary (optional) formatter.

Create phpcs.xml in your project root:

<?xml version="1.0"?>
<ruleset name="My Coding Standard">
    <file>app</file>
    <file>config</file>
    <file>database</file>
    <file>routes</file>
    <file>tests</file>

    <rule ref="IxDFCodingStandard"/>
</ruleset>

On top of the Generic, PSR and Slevomat rulesets, IxDFCodingStandard ships its own sniffs. Some run by default; some are opt-in. See docs/README.md for the full list and configuration.

Run it:

vendor/bin/phpcbf   # fix
vendor/bin/phpcs    # check (dry-run)

Composer scripts (recommended)

Wire both tools into composer.json so the whole team runs them the same way:

composer cs

cs fixes files in place. Edit composer.json:

{
    "scripts": {
        "cs": ["@php-cs-fixer", "@phpcbf"],
        "phpcbf": "phpcbf -p",
        "phpcs": "phpcs -p -s --report-full --report-summary",
        "php-cs-fixer": "php-cs-fixer fix --no-interaction --ansi --quiet"
    }
}

3. Continuous integration

Run the fixer in CI and commit the result back, so the branch is always formatted without blocking the build. This repository dogfoods that pattern; copy its workflow as a starting point: .github/workflows/coding-standard.yml.

About

🪷 PHPCS coding-standard for Laravel applications and packages

Topics

coding-stylelaravelphpcs-standard

Resources

Readme
Activity
Custom properties

Stars

7 stars

Watchers

7 watching

Forks

1 fork
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.