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
Coding Standard

Coding Standard Laravel Package

shipmonk/coding-standard

ShipMonk’s PHP coding standard built on PHP_CodeSniffer and Slevomat rules. Install as a dev dependency, add a phpcs.xml.dist referencing ShipMonkCodingStandard, then run phpcs to check code and phpcbf to auto-fix issues.

View on GitHub
Deep Wiki
Context7

ShipMonk Coding Standard is a PHP_CodeSniffer ruleset used across ShipMonk projects to keep code style consistent and enforce best practices. It’s primarily intended for ShipMonk packages, but can be integrated into any PHP codebase via a phpcs.xml.dist ruleset.

Features

  • Built on PHP_CodeSniffer with a ready-to-use ShipMonkCodingStandard ruleset
  • Integrates with slevomat/coding-standard via installed_paths
  • Supports both checking (phpcs) and auto-fixing (phpcbf) workflows
  • Simple configuration for targeting src/ and tests/ directories
Frequently asked questions about Coding Standard
Is ShipMonkCodingStandard compatible with Laravel projects, or should I use Laravel Pint instead?
This package enforces ShipMonk’s internal PHP standards, which may conflict with Laravel’s idiomatic patterns like Facades or middleware exception handling. While it works technically, you’ll need to exclude Laravel-specific directories (e.g., `app/Http/Middleware`) or disable conflicting rules (e.g., `CatchExceptionsOrder`). For Laravel-specific linting, tools like Laravel Pint or PHPStan are often better choices.
How do I install ShipMonkCodingStandard in a Laravel project?
Run `composer require --dev shipmonk/coding-standard` in your project root. Then, create a `phpcs.xml.dist` file with the provided template, ensuring the `installed_paths` includes both `slevomat/coding-standard` and `shipmonk/coding-standard`. The package assumes a `src/` and `tests/` directory structure, which may need adjustment for Laravel’s `app/` layout.
Will phpcbf break my Laravel application if I run it automatically?
Yes, there’s a risk. The package’s auto-fix (phpcbf) could reorder use statements for Facades, alter exception handling in middleware, or modify Laravel-specific patterns like trait usage. Always test with `phpcbf --dry-run` first or disable auto-fix for Laravel-specific files. Manual review is recommended for critical components.
Does ShipMonkCodingStandard support PHP versions older than 8.5?
No, this package explicitly requires PHP 8.5+ due to its dependency on `slevomat/coding-standard@^8.25.0`. If your Laravel project uses an older PHP version, you’ll encounter integration issues or rule conflicts. Consider using an older version of `slevomat/coding-standard` or a different ruleset like PSR-12 for broader compatibility.
Can I customize or override the rules for my Laravel project?
The package discourages external customization per ShipMonk’s README. To adapt it, you’d need to fork the package or exclude specific rules in your `phpcs.xml.dist`. However, this increases maintenance overhead. For Laravel-specific adjustments, it’s often better to use a modular tool like PHPStan or Rector alongside this package.
How does ShipMonkCodingStandard interact with PHPStan or Laravel Pint?
There’s no built-in conflict resolution. Rules like `ReturnTypeDeclaration` in ShipMonkCodingStandard may overlap with PHPStan’s expectations or Laravel Pint’s auto-fixing behavior, leading to redundant checks or false positives. Run tools sequentially and manually review conflicts, or disable overlapping rules in your configuration.
What Laravel-specific patterns might conflict with this coding standard?
Common conflicts include Facade use statement ordering, exception handling in middleware (e.g., `CatchExceptionsOrder`), and Eloquent model conventions. The package’s strict trait and method ordering rules may also flag Laravel’s implicit patterns as violations. Exclude directories like `app/Http/` or disable specific sniffs to mitigate these issues.
Is ShipMonkCodingStandard suitable for CI/CD pipelines in Laravel projects?
Yes, but configure it carefully. Use pre-commit hooks or gradual adoption strategies to avoid blocking merges due to strict rules. Pair it with `phpcbf --dry-run` in CI to test auto-fixes before applying them. For Laravel, consider running it only on non-critical paths (e.g., `src/`) or alongside other tools like PHPStan.
What alternatives exist for Laravel-specific PHP coding standards?
For Laravel projects, consider `laravel/pint` for auto-fixing style issues, `phpstan/phpstan` for static analysis, or `dealerdirect/phpcodesniffer-composer-normalizer` for Composer-specific rules. If you need a PHP_CodeSniffer-based solution, `slevomat/coding-standard` (without ShipMonk’s wrapper) offers more flexibility for customization.
How do I exclude Laravel’s app directory from ShipMonkCodingStandard checks?
In your `phpcs.xml.dist`, wrap the `<file>` tags with `<exclude-pattern>` to skip Laravel-specific directories. For example, add `<exclude-pattern>app/</exclude-pattern>` under `<file>src/</file>` to ignore the `app/` folder entirely. Alternatively, disable specific sniffs (e.g., `CatchExceptionsOrder`) for targeted exclusions.
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