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 opinionated conventions (e.g., facades, controllers, migrations). It leverages Laravel’s ecosystem (e.g., php artisan tlint) and integrates seamlessly with existing tooling (e.g., CI/CD, IDE plugins).FullyQualifiedFacades or NoDump). This fits well with teams prioritizing incremental codebase improvements.composer require, config file). Compatible with Laravel’s autoloading and service container.tighten, laravel) reduce configuration overhead. Custom presets can be defined via tlint.json.php artisan tlint) and API usage (e.g., in CI pipelines or IDE hooks). Example:
$result = (new \Tighten\TLint\TLint())->lint(app_path('Http/Controllers/'));
NoDump catching dd() in tests). Mitigate via .tlint.json exclusions or --ignore flags.@if conditions). Test with real-world templates.duster and php-parser add ~5MB to vendor/. Justify for teams with strict size constraints.--fix vs. manual fixes).TLint or writing custom linters.--paths config.tlint before static analyzers).tlint versions and resolve breaking changes (e.g., v7.0.0’s PHP version drop)?php artisan tlint aligns with Laravel’s workflow.$this->app->singleton(\Tighten\TLint\TLint::class, fn() => new \Tighten\TLint\TLint());
tlint before pint).php artisan tlint --fail-on-errors.- name: Lint Code
run: php artisan tlint --preset=laravel --paths=app,config
laravel-shift/tlint-vscode).NoDump, FullyQualifiedFacades) using --only flag.php artisan tlint --only=NoDump,FullyQualifiedFacades --paths=app/Http
--fix for auto-correctable issues (e.g., SpacesAroundBladeRenderContent).php artisan tlint --preset=tighten --fix
.tlint.json to exclude legacy paths or adjust severity:
{
"presets": ["laravel"],
"paths": ["app", "config"],
"ignore": ["app/OldLegacyCode"],
"severity": {
"NoDump": "warning"
}
}
php artisan tlint --fail-on=errors --severity=warning
composer.json constraints).UseAnonymousMigrations) target specific Laravel versions (≥8.37.0).php-mbstring is installed for path handling.--paths) but may need adjustments for multi-package setups.php-parser version).composer require --dev tightenco/tlint
php artisan vendor:publish --provider="Tighten\TLint\TLintServiceProvider" --tag="tlint-config"
app/Http/Controllers) to validate false positives.php artisan tlint --preset=laravel --paths=app/Http/Controllers --format=json > lint-results.json
OneLineBetweenClassVisibilityChanges if team prefers compact classes.tlint releases for breaking changes (e.g., v7.0.0’s PHP version drop).composer require tightenco/tlint with --update-with-dependencies for minor updates.TLint.$this->app->extend(\Tighten\TLint\Linters\NoDump::class, fn() => new CustomNoDumpLinter());
.tlint.json in the repo root to avoid per-developer overrides.php artisan tlint:config to generate a baseline config.--paths to limit scope (e.g., exclude vendor/).--ignore=resources/views/*.--verbose or --format=json for machine-readable output.parallel-lint wrappers.
Example:
find app -name "*.php" | xargs -P 4 -I {} php artisan tlint --paths={}
How can I help you explore Laravel packages today?