Skip to content

Instantly share code, notes, and snippets.

@michaelsieminski
Last active April 1, 2025 15:12
Show Gist options
  • Save michaelsieminski/00ec2d6e6d3d3ad21a2575ab5ac573ea to your computer and use it in GitHub Desktop.
Save michaelsieminski/00ec2d6e6d3d3ad21a2575ab5ac573ea to your computer and use it in GitHub Desktop.
Modern PHP Tooling

Modern PHP Tooling

This is my personal collection of modern PHP Tooling that I setup for all of my Laravel projects.

Linting & Types

  1. Pint - Formatting
  1. PeckPHP - Fix Typos
  1. RectorPHP - Use modern php syntax
  1. Larastan - Laravel Code Analysis

Testing

  1. PestPHP - Testing Framework
  • Install PestPHP
  • In phpunit.xml comment in DB_CONNECTION & DB_DATABASE variables
  1. Pest Type Coverage - Measure Type Coverage in the Code

Development Tools

  1. Clockwork - Identify Performance Issues
  1. Solo - Merge all running Terminals into one
  • Install Solo
  • Setup commands in solo.php config
  1. Composer Scripts
  2. AppServiceProvider
<?php
declare(strict_types=1);
namespace App\Providers;
use App\Models\Agency;
use Carbon\CarbonImmutable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;
final class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
$this->configureCommands();
$this->configureModels();
$this->configurePasswordValidation();
$this->configureDates();
}
/**
* Configure the application's commands.
*/
private function configureCommands(): void
{
DB::prohibitDestructiveCommands(
$this->app->isProduction()
);
}
/**
* Configure the models.
*/
private function configureModels(): void
{
Model::shouldBeStrict(! $this->app->isProduction());
Model::unguard();
}
/**
* Configure the password validation rules.
*/
private function configurePasswordValidation(): void
{
Password::defaults(fn () => $this->app->isProduction() ? Password::min(8)->uncompromised() : null);
}
/**
* Configure the dates.
*/
private function configureDates(): void
{
Date::use(CarbonImmutable::class);
}
}
"scripts": {
"lint": "pint",
"refactor": "rector",
"test:lint": "pint --test",
"test:refactor": "rector --dry-run",
"test:types": "phpstan analyse",
"test:arch": "pest --filter=arch",
"test:type-coverage": "pest --type-coverage --min=100",
"test:unit": "pest --parallel --coverage --exactly=99.4",
"test": [
"@test:lint",
"@test:refactor",
"@test:types",
"@test:type-coverage",
"@test:unit"
]
}
includes:
- vendor/larastan/larastan/extension.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
parameters:
level: max
paths:
- app
- config
- bootstrap
- database/factories
- routes
{
"preset": "laravel",
"rules": {
"array_push": true,
"backtick_to_shell_exec": true,
"declare_strict_types": true,
"final_class": true,
"fully_qualified_strict_types": true,
"global_namespace_import": {
"import_classes": true,
"import_constants": true,
"import_functions": true
},
"ordered_class_elements": {
"order": [
"use_trait",
"case",
"constant",
"constant_public",
"constant_protected",
"constant_private",
"property_public",
"property_protected",
"property_private",
"construct",
"destruct",
"magic",
"phpunit",
"method_abstract",
"method_public_static",
"method_public",
"method_protected_static",
"method_protected",
"method_private_static",
"method_private"
],
"sort_algorithm": "none"
},
"ordered_interfaces": true,
"ordered_traits": true,
"protected_to_private": true,
"strict_comparison": true
}
}
'commands' => [
'Vite' => 'bun dev',
'Logs' => EnhancedTailCommand::file(storage_path('logs/laravel.log')),
'Tests' => Command::from('php artisan test --colors=always --parallel')->lazy(),
'Pint' => Command::from('./vendor/bin/pint')->lazy(),
'Peck' => Command::from('./vendor/bin/peck')->lazy(),
'Reverb' => Command::from('php artisan reverb')->lazy(),
'Queue' => Command::from('php artisan queue:work')->lazy(),
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment