pyaesoneaung/laravel-starter-kit

Laravel 12 starter kit with built-in strict typing, enhanced code quality tools, and safety features.

v0.0.1 2025-05-05 06:21 UTC

This package is auto-updated.

Last update: 2025-05-05 06:44:27 UTC


README

Laravel Starter Kit

Laravel 12 starter kit with built-in strict typing, enhanced code quality tools, and safety features.

Features

✅ Strict Models

Model::shouldBeStrict();

This does three things:

  1. Prevents lazy loading
  2. It prevents silently discarding attributes.
  3. It prevents accessing missing attributes.

✋ Prevent Destructive Commands

Preventing the execution of destructive commands in production environments.

DB::prohibitDestructiveCommands(app()->isProduction());

⚡️ Automatic Relation Loading

Laravel can automatically eager load the relationships you access.

Model::automaticallyEagerLoadRelationships();

🪝 Git Commit Hook

Run duster lint for PHPStan, duster fix for refactor with Rector, and format with Laravel Pint before every commit.

Default Laravel Rector Rules

EloquentMagicMethodToQueryBuilderRector
 use App\Models\User;

-$user = User::find(1);
+$user = User::query()->find(1);
EloquentWhereRelationTypeHintingParameterRector
-User::whereHas('posts', function ($query) {
+User::whereHas('posts', function (Builder $query) {
     $query->where('is_published', true);
 });

-$query->whereHas('posts', function ($query) {
+$query->whereHas('posts', function (Builder $query) {
     $query->where('is_published', true);
 });
EloquentWhereTypeHintClosureParameterRector
 /** @var \Illuminate\Contracts\Database\Query\Builder $query */
-$query->where(function ($query) {
+$query->where(function (Builder $query) {
     $query->where('id', 1);
 });
ModelCastsPropertyToCastsMethodRector
 use Illuminate\Database\Eloquent\Model;

 class Person extends Model
 {
-    protected $casts = [
-        'age' => 'integer',
-    ];
+    protected function casts(): array
+    {
+        return [
+            'age' => 'integer',
+        ];
+    }
 }
ScopeNamedClassMethodToScopeAttributedClassMethodRector
 class User extends Model
 {
-    public function scopeActive($query)
+    #[\Illuminate\Database\Eloquent\Attributes\Scope]
+    protected function active($query)
     {
         return $query->where('active', 1);
     }
 }
WhereToWhereLikeRector
-$query->where('name', 'like', 'Rector');
-$query->orWhere('name', 'like', 'Rector');
-$query->where('name', 'like binary', 'Rector');
+$query->whereLike('name', 'Rector');
+$query->orWhereLike('name', 'Rector');
+$query->whereLike('name', 'Rector', true);

😺 GitHub Actions

Automated workflows for continuous integration, running Laravel Pint and PHPStan on every push and pull request.

Installation

laravel new --using pyaesoneaung/laravel-starter-kit my-app