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

Mo4 Coding Standard Laravel Package

mayflower/mo4-coding-standard

MO4 Coding Standard is a PHP CodeSniffer ruleset extending the Symfony standard with extra rules for array alignment and formatting, property doc blocks, namespace usage, and string interpolation. Install it via Composer to enforce consistent, modern PHP coding conventions across your projects.

View on GitHub
Deep Wiki
Context7

MO4 Coding Standard Rules for Codesniffer based on Symfony Coding Standards.

Frequently asked questions about Mo4 Coding Standard
How do I install the MO4 coding standard in my Laravel project?
Run `composer require --dev mayflower/mo4-coding-standard` to install the package. Then configure PHP_CodeSniffer to use the MO4 standard by adding `<config name="standard" value="MO4"/>` to your `phpcs.xml` or `phpcs.xml.dist` file.
Does this package work with Laravel’s default PSR-12 coding standard?
Yes, but some rules overlap (e.g., array formatting). You can disable conflicting PSR-12 rules in your `phpcs.xml` or use MO4 as a supplement. The package is designed to extend Symfony’s standard, which Laravel already aligns with.
Can I customize the sorting order for `use` statements in MO4?
Yes, the `AlphabeticalUseStatements` rule supports configuration. Add `<rule ref="MO4.Formatting.AlphabeticalUseStatements" parameters="order=custom_function"/>` to your `phpcs.xml` and define the sorting logic in a PHP function.
What Laravel versions are compatible with this package?
The package requires PHP 8.1+ (for v11.0.0) and works with Laravel 9+. For older Laravel versions (e.g., 8.x), use MO4 v10.x, which supports PHP 7.2+. Check your Laravel and PHP version compatibility before installing.
How do I auto-fix MO4 violations in my Laravel project?
Use `phpcbf` (PHP_CodeSniffer’s built-in fixer) with the MO4 standard. Run `./vendor/bin/phpcbf --standard=MO4 app/` in your terminal. Most formatting rules (e.g., array alignment, use statement ordering) can be auto-fixed.
Will this package slow down my CI/CD pipeline?
Running CodeSniffer on large codebases can introduce overhead. Mitigate this by caching results (`phpcs --cache`) or running checks selectively (e.g., `phpcs app/ --ignore=tests/`). For CI, consider parallelizing checks or excluding non-critical files.
Are there any known conflicts with Laravel-specific coding practices?
Minimal conflicts exist, but some rules (e.g., `MO4.Arrays.MultiLineArray`) may differ from Laravel’s default PSR-12 array formatting. Audit your `phpcs.xml` to disable conflicting rules or adjust MO4’s configuration to match your team’s preferences.
How do I integrate MO4 into GitHub Actions for pre-commit checks?
Add a step to your workflow YAML like this: `- name: Run MO4 CodeSniffer run: ./vendor/bin/phpcs --standard=MO4 --warning-severity=0 app/`. Configure severity levels (e.g., `--error-severity=5`) to fail builds on critical violations.
Can I use MO4 alongside other coding standards like PHPStan or Psalm?
Yes, MO4 is a standalone CodeSniffer ruleset and doesn’t interfere with static analysis tools like PHPStan or Psalm. Use MO4 for formatting and style consistency while relying on PHPStan/Psalm for type safety and logic errors.
What should I do if MO4 flags false positives in legacy Laravel code?
Disable specific rules for legacy code by adding `<rule ref="MO4.RuleName" severity="0"/>` to your `phpcs.xml`. Alternatively, whitelist files or directories using `<file>...</file>` or `<exclude-pattern>...</exclude-pattern>` tags.
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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel