Laravel 13: Features, Helpers &amp; Upgrade Notes | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. Laravel 13: New Features, Helpers, and Practical Upgrade Notes

 Laravel 13: New Features, Helpers, and Practical Upgrade Notes
===============================================================

 Laravel 13 ships with async-first primitives, a revised bootstrapping layer, and several quality-of-life helpers. Here is what actually matters for production apps and how to upgrade without surprises.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 9 Jul 2026 · Updated 9 Jul 2026 · 4 min read

ShareCopy linkCopied

 ![Laravel 13: New Features, Helpers, and Practical Upgrade Notes](https://cdn.msaied.com/404/bdf42eb6d0b2dba65e7248a284b40cf2.png) 

  On this page +1. [What Laravel 13 Actually Changes](#what-laravel-13-actually-changes)
2. [Bootstrapping and Application Lifecycle](#bootstrapping-and-application-lifecycle)
3. [New Helpers Worth Knowing](#new-helpers-worth-knowing)
4. [rescue\_unless](#coderescue-unlesscode)
5. [str()-&gt;toBase64url() and fromBase64url()](#codestr-gttobase64urlcode-and-codefrombase64urlcode)
6. [Collection::groupByMany()](#codecollectiongroupbymanycode)
7. [PHP 8.3 Integrations](#php-83-integrations)
8. [Breaking Changes to Watch](#breaking-changes-to-watch)
9. [Illuminate\\Http\\Client\\Response::json() strict mode](#codeilluminatehttpclientresponsejsoncode-strict-mode)
10. [Removed: $loop variable in Blade @each](#removed-codeloopcode-variable-in-blade-code-at-eachcode)
11. [Queue after\_commit default](#queue-codeafter-commitcode-default)
12. [Upgrade Checklist](#upgrade-checklist)
13. [Key Takeaways](#key-takeaways)

 What Laravel 13 Actually Changes
--------------------------------

Laravel 13 is a focused release. Rather than a sweeping API redesign, it tightens the framework's internals, promotes PHP 8.3 features to first-class status, and ships a handful of helpers that remove common boilerplate. The upgrade path from Laravel 12 is intentionally narrow — most apps need only a few targeted changes.

---

Bootstrapping and Application Lifecycle
---------------------------------------

The `Application` bootstrap sequence now exposes a dedicated `booting` / `booted` hook pair directly on the application instance, giving you a cleaner place to register deferred work without abusing service providers.

```php
// bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(web: __DIR__.'/../routes/web.php')
    ->booting(function (Application $app) {
        // Runs before any provider boot() is called.
        $app->bind(ReportFormatter::class, JsonReportFormatter::class);
    })
    ->booted(function (Application $app) {
        // All providers are booted; safe to resolve.
        $app->make(MetricsCollector::class)->register();
    })
    ->create();

```

This replaces the pattern of creating a throwaway service provider just to hook into the lifecycle.

---

New Helpers Worth Knowing
-------------------------

### `rescue_unless`

The inverse of `rescue()`. It runs the callback only when the condition is falsy, swallowing exceptions and returning a default — useful for optional third-party calls:

```php
$price = rescue_unless(
    condition: $this->cache->has('price:'.$sku),
    callback: fn () => $this->pricingApi->fetch($sku),
    rescue: null
);

```

### `str()->toBase64url()` and `fromBase64url()`

URL-safe Base64 encoding lands on the `Stringable` fluent API, removing the need for manual `strtr` gymnastics:

```php
$token = str($payload)->toBase64url();
$decoded = str($token)->fromBase64url();

```

### `Collection::groupByMany()`

Groups a collection by multiple keys in a single pass, returning a nested structure:

```php
$grouped = $orders->groupByMany(['region', 'status']);
// $grouped['EU']['pending'] => Collection of orders

```

---

PHP 8.3 Integrations
--------------------

Laravel 13 requires PHP 8.2 minimum and is optimised for 8.3. Typed class constants are now used throughout the framework's own codebase, and the `json_validate()` built-in replaces several internal `json_decode` + error-check patterns. Your own code can follow the same idiom:

```php
// Before
$valid = json_decode($raw, true) !== null && json_last_error() === JSON_ERROR_NONE;

// After (PHP 8.3)
$valid = json_validate($raw);

```

Readonly class promotion is also used in new stubs, so generated DTOs and form requests lean on `readonly` properties by default.

---

Breaking Changes to Watch
-------------------------

### `Illuminate\Http\Client\Response::json()` strict mode

Passing an invalid JSON body no longer silently returns `null`; it throws `JsonException`. Wrap legacy HTTP client calls:

```php
try {
    $data = Http::get($url)->json();
} catch (\JsonException $e) {
    Log::warning('Malformed API response', ['url' => $url]);
    $data = [];
}

```

### Removed: `$loop` variable in Blade `@each`

The `$loop` magic variable inside `@each` directives was deprecated in Laravel 12 and is removed in 13. Replace `@each` with `@foreach` to retain loop metadata.

### Queue `after_commit` default

The `after_commit` flag on dispatched jobs now defaults to `true` when a database transaction is active. If you rely on jobs firing mid-transaction for testing or side-effects, set `public bool $afterCommit = false` explicitly on the job class.

---

Upgrade Checklist
-----------------

- Run `composer require laravel/framework:^13.0` and fix any immediate constraint failures.
- Search for `@each` in Blade templates and convert to `@foreach`.
- Audit HTTP client calls that parse JSON — add `JsonException` handling.
- Review jobs that dispatch inside transactions; verify `$afterCommit` intent.
- Update `phpunit.xml` to the Laravel 13 stub if you are on PHPUnit 11.
- Run `php artisan config:clear && php artisan cache:clear` after deployment.

---

Key Takeaways
-------------

- The new `booting` / `booted` hooks on `Application` reduce throwaway service providers.
- `rescue_unless`, `toBase64url`, and `groupByMany` cover real day-to-day gaps.
- `Http::json()` now throws on bad JSON — handle it explicitly.
- `@each` is gone; `after_commit` defaults changed for queued jobs.
- PHP 8.3 is the sweet spot; `json_validate()` and readonly properties are first-class.

- [laravel](https://www.msaied.com/public/articles?search=laravel)
- [laravel-13](https://www.msaied.com/public/articles?search=laravel-13)
- [php](https://www.msaied.com/public/articles?search=php)
- [upgrade](https://www.msaied.com/public/articles?search=upgrade)

 Frequently asked questions 
---------------------------

  Is the upgrade from Laravel 12 to 13 disruptive?For most apps, no. The main breaking changes are the Http client throwing JsonException on bad JSON, the removal of $loop inside @each, and the changed after\_commit default for jobs. A focused audit of those three areas covers the majority of upgrade work.

   Does Laravel 13 require PHP 8.3?No — the minimum is PHP 8.2. However, the framework is optimised for 8.3 and uses features like json\_validate() and typed class constants internally. Running 8.3 gives you the best performance and the cleanest code alignment with the new stubs.

   What replaces the @each directive now that it is removed?Use a standard @foreach loop. The @each directive was a convenience wrapper that never supported the full $loop variable reliably. Switching to @foreach gives you $loop, better IDE support, and clearer template logic.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com/public#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLaravel New in 12: First-Class Typed Config, Slim Skeletons, and Upgrade Notes](https://www.msaied.com/public/articles/laravel-new-in-12-first-class-typed-config-slim-skeletons-and-upgrade-notes) [Next articleEloquent Custom Relations: Building a HasManyThrough Alternative for Complex Joins](https://www.msaied.com/public/articles/eloquent-custom-relations-building-a-hasmanythrough-alternative-for-complex-joins)  

   On this page
-------------

1. [What Laravel 13 Actually Changes](#what-laravel-13-actually-changes)
2. [Bootstrapping and Application Lifecycle](#bootstrapping-and-application-lifecycle)
3. [New Helpers Worth Knowing](#new-helpers-worth-knowing)
4. [rescue\_unless](#coderescue-unlesscode)
5. [str()-&gt;toBase64url() and fromBase64url()](#codestr-gttobase64urlcode-and-codefrombase64urlcode)
6. [Collection::groupByMany()](#codecollectiongroupbymanycode)
7. [PHP 8.3 Integrations](#php-83-integrations)
8. [Breaking Changes to Watch](#breaking-changes-to-watch)
9. [Illuminate\\Http\\Client\\Response::json() strict mode](#codeilluminatehttpclientresponsejsoncode-strict-mode)
10. [Removed: $loop variable in Blade @each](#removed-codeloopcode-variable-in-blade-code-at-eachcode)
11. [Queue after\_commit default](#queue-codeafter-commitcode-default)
12. [Upgrade Checklist](#upgrade-checklist)
13. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
