setono/code-quality-pack
Laravel-friendly code quality pack with ready-to-use tools and config for static analysis, coding standards, refactoring, and CI checks. Helps keep projects consistent and maintainable with minimal setup, ideal for teams and shared repositories.
Installation Add the package via Composer:
composer require --dev setono/code-quality-pack
Publish the package's configuration (if applicable):
php artisan vendor:publish --provider="Setono\CodeQualityPack\CodeQualityPackServiceProvider"
First Use Case Run the default code quality checks via Artisan:
php artisan code-quality:check
This executes all configured tools (e.g., PHPStan, Psalm, PHPMD, etc.) in a single command.
Where to Look First
config/code-quality-pack.php for tool-specific settings (e.g., PHPStan paths, Psalm levels).vendor/setono/code-quality-pack/src/Console/ (e.g., php artisan code-quality:phpstan).php artisan code-quality:install-git-hooks for pre-commit/pre-push checks.CI/CD Integration
- name: Run Code Quality Checks
run: php artisan code-quality:check --fail-on-error
Custom Tool Integration Extend the package by creating a custom tool:
// app/Providers/CodeQualityPackServiceProvider.php
public function register()
{
$this->app->singleton(ToolInterface::class, function () {
return new CustomTool();
});
}
Parallel Execution
Run tools in parallel using Laravel’s process helper or parallel-lint:
php artisan code-quality:phpstan --parallel &
php artisan code-quality:psalm --parallel &
postcss/webpack.mix.js for frontend checks (e.g., ESLint).// config/code-quality-pack.php
'reporter' => \Setono\CodeQualityPack\Reporters\SlackReporter::class,
Configuration Conflicts
phpstan.neon) don’t conflict with the package’s defaults.--config flag to override:
php artisan code-quality:phpstan --config=custom/phpstan.neon
Performance Overhead
--tools to run specific tools:
php artisan code-quality:check --tools=phpstan,psalm
Git Hooks Pitfalls
# .git/hooks/pre-commit
composer install --no-dev || exit 1
--verbose for detailed logs:
php artisan code-quality:check --verbose
php artisan code-quality:phpstan --dry-run
Custom Rules Add tool-specific rules via config:
// config/code-quality-pack.php
'phpstan' => [
'rules' => [
'Setono\CodeQualityPack\Rules\CustomRule::class',
],
],
Event Listeners Listen for tool execution events:
// app/Listeners/CodeQualityEventListener.php
public function handle(ToolExecuted $event) {
Log::info("Tool {$event->tool} completed with status {$event->status}");
}
Dynamic Tool Loading Load tools dynamically based on environment:
// config/code-quality-pack.php
'tools' => env('CODE_QUALITY_TOOLS', 'phpstan,psalm,phpmd') === 'all' ? ['*'] : explode(',', env('CODE_QUALITY_TOOLS')),
How can I help you explore Laravel packages today?