Anvil
Anvil - The mobile companion for Laravel Forge. Available now. Download for iOS

Laravel Patches v4.0.0

We are excited to announce the release of Laravel Patches v4.0, featuring a completely rewritten test suite using Pest, enhanced CLI tools for better visibility, and robust safeguards for your patch workflow. This release focuses on developer experience and reliability, ensuring you can manage your database patches with the same confidence as your migrations.

2 min read - 2,695 views -

Laravel Patches v4 - Stability, Transparency, and Control

🚀 Key Features

1. Robust Status Command

The patch:status command has been overhauled to give you a clear, migration-style overview of your patches.

  • Detailed Table View: See exactly which patches ran, when, and their status at a glance.
  • Filtering: Quickly find what you need with --pending, --ran, or --batch=<number> filters.
  • Execution Metrics: Now tracks and displays execution time (ms) directly in the status output.

2. Dry Run Mode

Preview your operation before committing to it.

  • Run php artisan patch --dry-run to see exactly which patches would execute without actually running them or modifying your database.
  • Perfect for double-checking the order of operations in production environments.

3. Atomic Transactions

Ensure your data integrity with built-in transaction support.

  • Configurable Safety: Patches now respect a global use_transactions config setting.
  • Granular Control: Override the global setting on a per-patch basis with the public bool $useTransaction property.
  • If a patch fails within a transaction, all database changes are automatically rolled back.

4. Detailed Metadata Tracking

Know exactly who, where, and how a patch was run. The patches table now automatically captures:

  • Execution Time: Performance tracking in milliseconds.
  • Memory Usage: Peak memory usage during the patch execution.
  • Authenticated User: Records the console user (or authenticated app user) who triggered the patch.
  • Environment: Logs the environment (local, production, staging) where the patch was executed.

5. Enhanced Error Handling

Failures are now first-class citizens.

  • Stop on Error: Configurable option to halt execution immediately if a patch fails, preventing cascading issues.
  • Failure Logging: Full exception messages and stack traces are logged directly to the database for failed patches, making debugging effortless.

6. Event System

Hook into the patch lifecycle with a new suite of events:

  • PatchExecuting / PatchExecuted
  • PatchFailed
  • PatchRollingBack / PatchRolledBack

Upgrading

To upgrade, update your composer.json dependency:

1"require": {
2 "rappasoft/laravel-patches": "^4.0"
3}

Then run composer update.

Testing

We have migrated our entire test suite to PestPHP, ensuring a modern, maintainable, and reliable foundation for future development. Run the suite locally with:

1composer test

Read next

Mastering Laravel’s data_get(): Read Anything from Arrays, Objects, and Collections

If you’ve ever written a long chain of null checks to fetch a deeply nested value — foo['bar']['baz'] ?? null — you’ll love Laravel’s data_get() helper. It’s a tiny, dependable utility that safely retrieves values from arrays, objects, ArrayAccess implementations, and even nested structures using a simple “dot notation.”

6 min read - 7,717 views -

Introducing Laravel Authentication Log

Laravel Authentication Log is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

AR
1 min read - 12,389 views -