Skip to content

You're browsing the documentation for an old version of Bag. Consider upgrading to the latest version.

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.