tightenco/tlint
Tighten’s opinionated linter for Laravel and PHP projects. Enforces consistent conventions and catches style issues using preset and custom rules, runnable via CLI or CI. Built on PHP_CodeSniffer with sensible Laravel-focused defaults.
tlint is purpose-built for Laravel, aligning with its ecosystem (e.g., presets for Laravel conventions like FullyQualifiedFacades, UseAnonymousMigrations, and RequestValidation). This reduces friction in adoption and ensures consistency with Laravel’s evolving standards (e.g., Laravel 11/13 compatibility in v9.x).--only flag for targeted checks). This fits well with modern CI/CD pipelines where incremental linting is preferred.dd()/dump() calls, blade directive spacing) without regex limitations. This is critical for enforcing complex Laravel patterns (e.g., facades, route paths).composer require tightenco/tlint and minimal config (tlint.json). No database migrations or service provider bindings are needed.tlint:fix) or CI pipelines (e.g., GitHub Actions). Example:
./vendor/bin/tlint --fix --preset=laravel
Process component for cross-platform execution (Windows/Linux/macOS), reducing environment-specific issues.NoCompact, NoDump) were deprecated. Ensure replacements (e.g., @ray detection in v9.5.0) meet team needs.SpacesAroundBladeRenderContent) may conflict with custom directives. Test edge cases like @inject or @stack.__call() or magic methods may still trigger issues.tlint --profile to identify bottlenecks (e.g., nested facades, complex route files).tlint’s presets (e.g., FullyQualifiedFacades, UseAnonymousMigrations)? If not, custom presets may be needed.- name: Run TLint
run: ./vendor/bin/tlint --preset=laravel --fail-on=warning
tlint:fix auto-correct issues (e.g., SpaceAfterBladeDirectives) or only report them? Balance developer productivity vs. merge conflicts.tests/, vendor/) be excluded? Use the paths config option:
{
"paths": ["app/", "routes/"]
}
dd() calls, unqualified facades) be addressed? A phased rollout with --ignore flags may be needed.tlint for style, PHPStan for logic).SpacesAroundBladeRenderContent), but tlint focuses on Laravel-specific rules.php-cs-fixer integration or custom tasks.tlint in dry mode to assess violations:
./vendor/bin/tlint --preset=laravel --format=checkstyle > tlint.xml
tlint.json to customize excluded paths/rules:
{
"presets": ["laravel"],
"exclude": ["app/Helpers/*.php"],
"rules": {
"NoDump": "error",
"FullyQualifiedFacades": "warning"
}
}
--fix for auto-correctable issues (e.g., blade spacing).NoDump) in CI with --fail-on=error.--ignore for temporary exclusions:
./vendor/bin/tlint --ignore="app/OldCode/*.php"
services:
php81: "8.1"
php82: "8.2"
php83: "8.3"
spatie/laravel-permission).php-parser or symfony/process (e.g., Laravel’s illuminate/support may bundle similar components).composer require --dev tightenco/tlint php-cs-fixer
tlint.json:
./vendor/bin/tlint --init
composer.json scripts:
"scripts": {
"lint": "tlint --preset=laravel",
"lint:fix": "tlint --fix"
}
{
"husky": {
"hooks": {
"pre-commit": "composer lint"
}
}
}
.github/workflows/lint.yml:
- name: TLint
run: composer lint
tlint.json may diverge from upstream presets. Mitigate by:
extends to inherit presets:
{
"extends": ["tighten"],
"rules": { ... }
}
composer update tightenco/tlint).composer why-not tightenco/tlint@7.0.0
php-parser and symfony/process may require updates. Test with:
./vendor/bin/tlint --profile
--debug to inspect AST nodes:
./vendor/bin/tlint --debug --only=NoDump
tlint.json:
{
"blade": {
"ignoredDirectives": ["@custom"]
}
}
database/migrations/).#code-quality channel.How can I help you explore Laravel packages today?