Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Code Style Laravel Package

ely/php-code-style

Opinionated PHP-CS-Fixer rule set from Ely.by for PHP 7.4+ projects. Install alongside friendsofphp/php-cs-fixer, add a .php-cs-fixer.php using Ely\CS\Config, optionally override rules, then run php-cs-fixer to lint and fix code style.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package alongside PHP-CS-Fixer as a development dependency:

composer require --dev friendsofphp/php-cs-fixer ely/php-code-style

Then create .php-cs-fixer.php using the provided config helper:

<?php
$finder = \PhpCsFixer\Finder::create()->in(__DIR__);
return \Ely\CS\Config::create()->setFinder($finder);

Run dry-run to preview style fixes:

vendor/bin/php-cs-fixer --diff --dry-run fix

Apply fixes:

vendor/bin/php-cs-fixer fix

This is the fastest path to get automatic formatting for Ely.by’s opinionated PSR-2/PSR-12-adjacent style.

Implementation Patterns

  • Default usage: Use \Ely\CS\Config::create() with no arguments for standard Ely.by rules—works with PHP 7.4+.
  • Override or extend rules: Pass a rules array to create() for minor tweaks, e.g., to enable trailing commas in method arguments and arrays:
    \Ely\CS\Config::create([
        'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments']],
    ])
    
  • Integrate into CI: Run php-cs-fixer --dry-run in CI pipelines to fail builds on style violations.
  • Pre-commit hook: Use a Git hook (e.g., via husky or manual hook) to run php-cs-fixer fix before commits.
  • IDE integration: Configure PHPStorm or VS Code to use php-cs-fixer as the formatter for PHP files—set to vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --path-mode=override --using-cache=no $FileDir$/$FileName$.

Gotchas and Tips

  • Custom fixers removed in v1.0.0: Older docs mention custom fixers (e.g., braces_fixer, self_accessor)—these have been moved to separate repo. Do not expect them in current releases.
  • Brace style is non-standard: Opening brace for classes goes on same line (class Foo {), but for methods it goes on the next line (function bar() {), violating typical PSR conventions—watch for merge conflicts during adoptations.
  • Blank line behavior: The config enforces a blank line before return only if there are multiple preceding statements (per blank_line_before_return), and a blank line after control structures (if, for, etc.). These are easily missed in diffs.
  • Parameter alignment off by design: Multiline function parameters intentionally avoid alignment (Ely\align_multiline_parameters disabled by default)—rely on natural indentation instead of equals-sign alignment.
  • PHP 8+ compatibility: Works with modern PHP, but some rules (e.g., declare(strict_types=1), readonly properties) are opinionated. Confirm compatibility with your target runtime.
  • No built-in cache or parallelization: Add --parallel and configure cache manually for larger repos to improve performance.
  • Debug rules: Use -vvv to see which fixers are applied and why, especially helpful when unexpected formatting occurs (e.g., comment_to_phpdoc preserves PHPStan suppressions and @todo).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport