Onion is a lightweight PHP package designed to facilitate layered processing within applications, It provides a clean and efficient way to stack layer

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-10-21 02:00:03

Onion is a lightweight PHP package designed to facilitate layered processing within applications, It provides a clean and efficient way to stack layers of functionality, allowing developers to create flexible and reusable components that can be easily composed and managed. Each layer can perform a specific operation on the data being passed through, making it simple to build complex workflows while maintaining clear separation of concerns.

The Onion object is the core component, representing a stack of layers that process data sequentially. Each layer can transform the input data and/or perform specific operations.

Layers are simple PHP Closures or classes that implement the Aldemeery\Onion\Interfaces\Invokable interface, and they are the essential building blocks of the Onion object, enabling you to define specific operations that are executed during processing. Layers are executed sequentially in the order they were added, with the output of one layer becoming the input of the next.

Once your layers are defined and added to the Onion object, you can execute the full stack of layers using the peel() method. This method takes an optional value and passes it as an argument to the first layer, from there the output of each layer is passed as the input of the next layer, with the output of the last layer being returned as the output of the Onion itself.

Leave a Comment