PHP code example of sufyandev / laravel-migration-linter

1. Go to this page and download the library: Download sufyandev/laravel-migration-linter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sufyandev / laravel-migration-linter example snippets


return [
    'severity_threshold' => 'warning',
    'rules' => [
        'AddNonNullableColumnWithoutDefault' => ['enabled' => true, 'severity' => 'warning'],
        'MissingIndexOnForeignKey'           => ['enabled' => true, 'severity' => 'warning'],
        // ... other rules
    ],
];
bash
php artisan migrate:lint
bash
php artisan migrate:lint --json > storage/lint-report.json
bash
php artisan migrate:lint --generate-baseline
bash
php artisan vendor:publish --tag="migration-linter-config"
yaml
name: Laravel Migration Linter
on: [push, pull_request]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
      - run: composer install --no-interaction
      - run: php artisan migrate:lint --json > lint-report.json
bash
php artisan migrate:lint                  # Still works
php artisan migrate:lint --json           # Still works
php artisan migrate:lint --generate-baseline  # Still works