<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf" -->

---
title: Laravel Rulebook: Business Rules That Change by Date
description: Laravel Rulebook is a new package by Mathias Onea for encoding business rules that change over time, letting each version of a rule declare its own validity...
canonical: https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Laravel Rulebook: Business Rules That Change by Date | daily.dev
og:description: Laravel Rulebook is a new package by Mathias Onea for encoding business rules that change over time, letting each version of a rule declare its own validity...
og:url: https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf
og:image: https://api.daily.dev/og/posts/2Z40ZtunF.png
og:image:alt: Laravel Rulebook: Business Rules That Change by Date
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel Rulebook: Business Rules That Change by Date

**[Laravel News](https://daily.dev/sources/ln)** · 6 min read · 32 upvotes · 2 comments

## Summary

Laravel Rulebook is a new package by Mathias Onea for encoding business rules that change over time, letting each version of a rule declare its own validity window with always(), from(), until(), or between(). Resolving a rulebook at a given point in time returns a single winning rule chosen by priority(), plus a full trace of every rule's status and reason, whether it applied, was skipped for being outside its validity window, or lost. It throws NoMatchingRule or AmbiguousRuleMatch when a decision can't be made cleanly, and a snapshot() method freezes a decision into a storable JSON record. It requires PHP 8.3 and Laravel 12 or 13, has no facade, registry, config, or migrations, and is intended for decisions that need to be explained after the fact, such as refunds or invoices under a since-changed policy, rather than for a single one-off date check.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://laravel-news.com/laravel-rulebook>

## Questions this post answers

### How can I version business rules in Laravel so old policies still apply to past dates?

The Laravel Rulebook package lets each rule declare the date window it was valid for using always(), from(), until(), or between() methods, so an old policy class stays in the codebase alongside the current one. Resolving a decision at a specific date picks exactly one winner by priority(), skipping rules whose validity window doesn't cover that date, and returns a reason explaining why each rule won or lost.

_Developers building policy or pricing logic that changes over time can track packages like this on daily.dev._

### What PHP and Laravel versions does the mathiasonea/laravel-rulebook package require?

It requires PHP 8.3 and Laravel 12 or 13, and installs via composer require mathiasonea/laravel-rulebook. There is no facade, registry, config file, or migration needed to use it.

_Anyone evaluating new Laravel packages can keep tabs on compatibility requirements via daily.dev._

### How do I record why a specific refund or business rule decision was made, so I can explain it later?

Call snapshot() on a resolved decision to freeze it into a JSON record with a schema version, timestamp, winning rule key, outcome, and every rule's evaluation status and reason, which can be stored alongside the record it applies to. Rules should be given an explicit key() rather than relying on the class name, since renaming a class would otherwise change the stored identifier in every past record.

_Teams needing explainable, auditable decisions can follow patterns like this for their own systems on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@pdfopsdev** · 1 upvotes

> interesting edge case is two rules with overlapping windows and equal priority, is resolution deterministic or does it fall back to insertion order under the hood? that's the part an audit actually cares about, not just which rule won but why the near miss didn't.

**@agustinbarrientos** · 0 upvotes

> Before saving the first snapshot, I'd give every rule a stable key. Renaming a class shouldn't turn an old decision into a new one.

## Similar posts on daily.dev

- [Rule Builders for Every Validation Rule in Laravel 13.36](https://daily.dev/posts/rule-builders-for-every-validation-rule-in-laravel-13-36-cnsk92y3u) · Laravel News · 2 upvotes · 1 comments
- [Fluent Rule Builders for All Laravel Validation Rules](https://daily.dev/posts/fluent-rule-builders-for-all-laravel-validation-rules-qqk2xpkvz) · Laravel News · 1 upvotes · 0 comments

---

Tags: [#open-source](https://daily.dev/tags/open-source), [#architecture](https://daily.dev/tags/architecture), [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Laravel Rulebook: Business Rules That Change by Date","url":"https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf"},"datePublished":"2026-09-07T13:45:46.984Z","dateModified":"2026-09-14T08:40:04.907Z","description":"Laravel Rulebook is a new package by Mathias Onea for encoding business rules that change over time, letting each version of a rule declare its own validity...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ad9661596eb61f4f05bede043d37f068?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ad9661596eb61f4f05bede043d37f068?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Laravel News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Laravel News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ln","url":"https://daily.dev/sources/ln"},"commentCount":2,"discussionUrl":"https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":32},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"open-source,architecture,php,laravel","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Laravel News","item":"https://daily.dev/sources/ln"},{"@type":"ListItem","position":3,"name":"Laravel Rulebook: Business Rules That Change by Date"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf","comment":[{"@type":"Comment","text":"interesting edge case is two rules with overlapping windows and equal priority, is resolution deterministic or does it fall back to insertion order under the hood? that’s the part an audit actually cares about, not just which rule won but why the near miss didn’t.","datePublished":"2026-09-08T18:04:34.490Z","url":"https://daily.dev/posts/2Z40ZtunF#c-JBcaDe0Rb","author":{"@type":"Person","name":"PDFops","url":"https://daily.dev/pdfopsdev","image":"https://media.daily.dev/image/upload/s---8isRBKc--/f_auto/v1782922291/avatars/avatar_orjMeK8QKaaVZwGq7ScPz?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Before saving the first snapshot, I’d give every rule a stable key. Renaming a class shouldn’t turn an old decision into a new one.","datePublished":"2026-09-09T08:04:54.978Z","url":"https://daily.dev/posts/2Z40ZtunF#c-yUSbNASSu","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/laravel-rulebook-business-rules-that-change-by-date-2z40ztunf#faq","mainEntity":[{"@type":"Question","name":"How can I version business rules in Laravel so old policies still apply to past dates?","acceptedAnswer":{"@type":"Answer","text":"The Laravel Rulebook package lets each rule declare the date window it was valid for using always(), from(), until(), or between() methods, so an old policy class stays in the codebase alongside the current one. Resolving a decision at a specific date picks exactly one winner by priority(), skipping rules whose validity window doesn't cover that date, and returns a reason explaining why each rule won or lost. Developers building policy or pricing logic that changes over time can track packages like this on daily.dev."}},{"@type":"Question","name":"What PHP and Laravel versions does the mathiasonea/laravel-rulebook package require?","acceptedAnswer":{"@type":"Answer","text":"It requires PHP 8.3 and Laravel 12 or 13, and installs via composer require mathiasonea/laravel-rulebook. There is no facade, registry, config file, or migration needed to use it. Anyone evaluating new Laravel packages can keep tabs on compatibility requirements via daily.dev."}},{"@type":"Question","name":"How do I record why a specific refund or business rule decision was made, so I can explain it later?","acceptedAnswer":{"@type":"Answer","text":"Call snapshot() on a resolved decision to freeze it into a JSON record with a schema version, timestamp, winning rule key, outcome, and every rule's evaluation status and reason, which can be stored alongside the record it applies to. Rules should be given an explicit key() rather than relying on the class name, since renaming a class would otherwise change the stored identifier in every past record. Teams needing explainable, auditable decisions can follow patterns like this for their own systems on daily.dev."}}]}
```

