Weave 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
Coding Style

Coding Style Laravel Package

worksome/coding-style

Worksome Coding Style provides shared ECS, PHPStan, and Rector configuration for Laravel/PHP projects. Install via Composer, generate the config stubs, add the scripts, and run them to enforce consistent formatting and static analysis.

View on GitHub
Deep Wiki
Context7

Worksome Coding Style is a shared coding-standard package that bundles ready-made configuration for ECS, PHPStan, and Rector, giving Laravel/PHP projects consistent formatting, static analysis, and automated refactoring out of the box. It extends the PSR-12 base rule set with Worksome's own opinionated customisations.

  • One-command setup with composer generate-coding-style-stubs
  • Prebuilt Composer scripts for linting, fixing, analysis, and refactoring
  • Customised fixers for array syntax, binary operators, blank lines, and class attributes
  • Unified standards across all Worksome PHP projects
Frequently asked questions about Coding Style
How do I install and set up worksome/coding-style in a Laravel project?
Run `composer require --dev worksome/coding-style`, then generate configs with `composer generate-coding-style-stubs`. Add the predefined Composer scripts (`ecs`, `phpstan`, `rector`) to your `composer.json` under the `scripts` section. No additional Laravel-specific setup is required.
Does this package work with Laravel 10/11? Are there version compatibility issues?
The package is designed for modern Laravel projects (tested with Laravel 10+). It assumes PHP 8.1+, which aligns with Laravel’s latest LTS versions. Check the [GitHub releases](https://github.com/worksome/coding-style/releases) for confirmed compatibility if using older Laravel versions.
What happens if my code violates the DisallowEnvUsageSniff rule? Can I disable it?
The `DisallowEnvUsageSniff` rule blocks direct `env()` calls, which is a Laravel best practice. You can exclude specific lines with `@phpstan-ignore-next-line` or override the rule in your ECS config. However, consider refactoring to use dependency injection or config files instead.
Will this break my existing Laravel project if I run it immediately?
Running `composer ecs` or `composer phpstan` will flag violations, but most rules (like `SingleQuoteFixer`) are non-breaking. Start with `composer ecs:fix` to auto-correct safe issues, then triage custom rules (e.g., `DisallowHasFactorySniff`) incrementally. Use `--dry-run` flags to preview changes.
How does this differ from laravel-pint or depfu/laravel-phpstan?
Unlike `laravel-pint` (which focuses solely on formatting), this package combines **ECS (linting)**, **PHPStan (static analysis)**, and **Rector (refactoring)** with Laravel-specific rules (e.g., Blade/Artisan constraints). It’s more opinionated than `depfu/laravel-phpstan` but integrates all three tools seamlessly.
Can I customize or skip specific rules without disabling the entire package?
Yes. Override rules in your `.ecs.php` or `phpstan.neon` by extending the generated stubs. For example, to skip `PascalCasingEnumCasesSniff`, add it to the `skippedRules` array in ECS. The package provides clear documentation on excluded rules (e.g., `UnaryOperatorSpacesFixer`) in its [README](https://github.com/worksome/coding-style).
How should I integrate this into CI/CD for Laravel projects?
Add `composer ecs` and `composer phpstan` to your CI pipeline (e.g., GitHub Actions) to run on pull requests. Treat critical violations (e.g., PHPStan errors) as blocking, while warnings (e.g., ECS suggestions) can be logged. Use `rector:fix` for automated refactoring in pre-commit hooks with Husky.
Are there performance concerns running PHPStan and Rector in development?
PHPStan and Rector add minimal overhead during development (typically <1s for small/medium Laravel apps). For larger projects, cache results with `phpstan --generate-report` or run them in parallel via Composer scripts. In CI, prioritize speed by excluding tests or using `--memory-limit=1G` flags.
What if my team uses Pest PHP but the package enforces PHPUnit rules?
The `DisallowPHPUnit` rule is designed to encourage Pest adoption, but you can disable it by removing the custom sniff from the ECS config. Alternatively, extend the package’s ruleset to allow both frameworks. Check the [custom rules section](https://github.com/worksome/coding-style#additional-customised-rules) for overrides.
How do I handle false positives, like PascalCasingEnumCasesSniff flagging legitimate code?
False positives can be addressed by adding `@phpstan-ignore-line` or `@ecs-ignore` comments above the offending line. For recurring issues, override the rule in your config. The package’s custom sniffs are designed to be strict but provide clear error messages to help justify exceptions.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo