- What is longman/php-code-style and what does it do?
- longman/php-code-style is a set of opinionated coding-standard configuration files, primarily PHPCS-oriented, that you point your linter at to enforce consistent formatting. It ships no runtime application code and does not register a Laravel service provider, so it never loads in production. Think of it as a reference ruleset rather than a library.
- How do I install longman/php-code-style in a Laravel project?
- You can pull it in with composer require --dev longman/php-code-style, but most teams should instead copy the ruleset into a committed phpcs.xml.dist or pint.json. Because the last release was June 2017, adding it as a floating dev dependency risks rule names that no longer resolve in current PHP_CodeSniffer versions. Vendor or transcribe the config and pin your formatter to an exact version.
- Does longman/php-code-style work with Laravel and current Laravel versions?
- The ruleset is framework-agnostic, so it applies to Laravel projects as well as plain PHP codebases, but it has no awareness of Laravel-specific conventions. It predates Laravel Pint and the PSR-12 era, so its defaults may conflict with modern Laravel style. For current Laravel versions, use Pint with a pint.json and treat this package as a source of rule intent.
- Which tool does longman/php-code-style target, PHP_CodeSniffer or PHP-CS-Fixer?
- The overview describes it as PHPCS-oriented configuration, meaning it is intended for PHP_CodeSniffer rather than PHP-CS-Fixer, though you should inspect the repository to confirm exactly which files and sniff codes it ships. Rule naming differs significantly between PHP_CodeSniffer 2.x and 3.x, and between PHP-CS-Fixer 2.x and 3.x. Validate every rule against the engine version your team runs before enforcing it.
- Is longman/php-code-style still maintained and safe to use?
- No, upstream is effectively dormant: the last release was June 2017 and the package has no dependents providing a validation signal. There is low security risk because it ships no executable runtime code, so the CVE surface is minimal. The real risk is tool drift causing CI hard failures or false positives on modern syntax.
- Does longman/php-code-style support PHP 8 syntax like enums, readonly properties and attributes?
- Almost certainly not out of the box. A 2017-era ruleset predates enums, readonly properties and classes, constructor property promotion, attributes, and first-class callables, so it may under-cover them or actively reject valid PHP 8.x code. You will need to add modern-syntax exemptions and align with PSR-12. Gate adoption on your team's PHP version floor.
- Should I add longman/php-code-style to require-dev or vendor the config?
- Do not add it to require-dev as a floating dependency. Vendor the relevant config into the repository root or a tools/style directory and commit it so the standard is versioned with the code it governs. Pin the formatter itself, such as php-cs-fixer/shim or laravel/pint, to an exact release for deterministic CI.
- How do I adopt longman/php-code-style in CI without breaking the build?
- Run the config in report-only mode across the default branch first to quantify violation volume. Decide up front whether you will reformat or grandfather existing files, then land one mechanical reformat commit and register it in .git-blame-ignore-revs. Wire the formatter into pre-commit hooks as advisory and promote CI to blocking only after the baseline commit is merged.
- What are good alternatives to longman/php-code-style for Laravel code style enforcement?
- For Laravel shops the pragmatic choice is Laravel Pint, a PHP-CS-Fixer wrapper configured with pint.json. Non-Laravel projects can use PHP-CS-Fixer with the @PSR12 ruleset or PHP_CodeSniffer with PSR-12 and Slevomat sniffs. Easy Coding Standard is another maintained option if you want a single tool for both linting and formatting.
- How do I keep IDE formatting in sync with longman/php-code-style rules?
- Keep IDE auto-format parity with CI by configuring PhpStorm, or your editor of choice, to use the same formatter binary and ruleset version as the pipeline. Without that parity, developers get diff churn and reformat-only commits that obscure real changes. Pin the tool version in both places and document the inline-ignore and escalation path.