Skip to content

Bag

Immutable Value Objects for PHP

composer require dshafik/bag

What is Bag?

Bag helps you create immutable value objects. It's a great way to encapsulate data within your application.

Bag prioritizes immutability and type safety with built-in validation and data casting.

When should I use Value Objects?

Value objects should be used in place of regular arrays, allowing you enforce type safety and immutability.

Does it work with Laravel/Symfony/Other Framework?

Bag is framework-agnostic, but it works great with Laravel. Bag uses standard Laravel Collections and Validation. In addition, it will automatically inject Bag\Bag value objects into your controllers with validation.

Made with 🦁💖🏳️‍🌈 by Davey Shafik.