Download the PHP package brighten/immutable-model without Composer

On this page you can find all versions of the php package brighten/immutable-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package immutable-model

ImmutableModel

An Eloquent-compatible, read-only model kernel for Laravel 11+

ImmutableModel provides first-class, enforceable read-only models for Laravel applications. It's perfect for SQL views, read-only tables, denormalized projections, and as a CQRS read-side primitive.

What "Immutable" Means

ImmutableModel enforces database immutability, not strict object immutability:

Operation Allowed? Example
Read from database ✅ Yes User::find(1), User::where(...)->get()
In-memory attribute changes ✅ Yes $user->computed_field = 'value'
Database persistence ❌ Throws $user->save(), $user->update(), $user->delete()
Static write methods ❌ Throws User::create(), User::insert()

This design prevents accidental database writes while remaining compatible with common Laravel patterns like adding computed properties for API responses, serialization, and working with collections.

Why ImmutableModel?

Installation

Requirements

Quick Start

API Reference

Model Configuration

Querying

All standard Eloquent read operations are supported:

Relationships

Supported relationship types:

Casting

Full Eloquent casting support:

Custom casters must implement Illuminate\Contracts\Database\Eloquent\CastsAttributes. Only the get() method is called.

Collections

Query results return Laravel's standard Eloquent\Collection. All collection methods work normally - immutability is enforced on database operations, not on in-memory manipulation:

Pagination

Full pagination support:

Chunking & Lazy Loading

Global Scopes

Apply query constraints automatically using Laravel's native Scope interface:

Hydration from Raw Data

Create models from existing data without database queries:

Comparison: ImmutableModel vs Eloquent

Feature ImmutableModel Eloquent
Read queries Yes Yes
Relationships Yes Yes
Eager loading Yes Yes
Attribute casting Yes Yes
Accessors Yes Yes
Pagination Yes Yes
Global scopes Yes Yes
Write operations Throws Yes
Dirty tracking No Yes
Events/Observers No Yes
Mutators No Yes
Timestamps No Yes
Mass assignment No Yes

Performance

Benchmarks show ImmutableModel is significantly faster for read operations:

Hydration Speed

Rows Eloquent ImmutableModel Improvement
100 0.30ms 0.09ms -70%
1,000 3.09ms 0.80ms -74%
10,000 34.27ms 9.37ms -73%
100,000 447.29ms 236.63ms -47%

Memory Usage

Rows Eloquent ImmutableModel Per Model (E) Per Model (I) Savings
100 166 KB 97 KB 1.66 KB 998 B 41%
1,000 1.61 MB 973 KB 1.65 KB 996 B 41%
10,000 16.2 MB 9.56 MB 1.66 KB 1003 B 41%
100,000 161.5 MB 95.1 MB 1.65 KB 997 B 41%

Eager Loading (10 posts per user)

Users Models Eloquent Immutable Time Δ Eloquent Mem Immutable Mem Mem Δ
10 110 1.68ms 1.27ms -25% 184 KB 105 KB 43%
100 1,100 5.75ms 2.23ms -61% 1.76 MB 1.02 MB 42%
1,000 11,000 64.22ms 19.34ms -70% 17.53 MB 10.23 MB 42%

Use Cases

ImmutableModel is ideal for:

Not Intended For

Exceptions

Exception When Thrown
ImmutableModelViolationException Any database persistence attempt (save, update, delete, create, etc.)
ImmutableModelConfigurationException Invalid model configuration

Contributing

Contributions are welcome! Please ensure all tests pass before submitting a PR:

License

MIT License. See LICENSE for details.


All versions of immutable-model with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/database Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brighten/immutable-model contains the following files

Loading the files please wait ...