PHPackages                             returnearly/actions-pattern - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. returnearly/actions-pattern

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

returnearly/actions-pattern
===========================

 A minimal package for using the actions pattern in Laravel.

v2.0.0(3d ago)045.9k↓68.9%MITPHPPHP ^8.3CI passing

Since Sep 3Pushed 3d agoCompare

[ Source](https://github.com/returnearly/actions-pattern)[ Packagist](https://packagist.org/packages/returnearly/actions-pattern)[ Docs](https://github.com/returnearly/actions-pattern)[ GitHub Sponsors](https://github.com/returnearly)[ RSS](/packages/returnearly-actions-pattern/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (24)Versions (8)Used By (0)

Actions Pattern
===============

[](#actions-pattern)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e3fb6d9d080ef67cc0b85dae50896b6996a48308df508c61f35c2557976384be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72657475726e6561726c792f616374696f6e732d7061747465726e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/returnearly/actions-pattern)[![GitHub Tests Action Status](https://camo.githubusercontent.com/64a2316708ccbe189dec49a3142f0d9c54bfd90f1c9a9c498b997a22a6b5a7fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72657475726e6561726c792f616374696f6e732d7061747465726e2f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/returnearly/actions-pattern/actions?query=workflow%3Arun-tests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/df6a8bca301ffa36c0cacec2fd387914f770002120d3dd748acf046937f1228b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72657475726e6561726c792f616374696f6e732d7061747465726e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/returnearly/actions-pattern/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/9c7e3de111e941f04bc549a10fd26b2fc40c1dd5815b786b3a0be62e4aa12974/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72657475726e6561726c792f616374696f6e732d7061747465726e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/returnearly/actions-pattern)

A minimal package for using the actions pattern in Laravel.

What is the actions pattern?
----------------------------

[](#what-is-the-actions-pattern)

An **action** is a small, single-purpose class that encapsulates one unit of business logic — "process a refund", "register a user", "publish a post". Instead of scattering that logic across fat controllers, jobs, and listeners, you put it in one place and call it from anywhere.

Every action follows the same shape:

- It exposes **one** public entry point, `handle()` — the only method callers touch.
- Supporting logic lives in **private** methods, so the public surface stays small and the internals stay free to change.
- Its **dependencies arrive through the constructor** (repositories, services, even other actions). The action never reaches into the container itself, which keeps it trivial to test.
- Actions are **composed**, not wired into a pipeline: when one action needs another, it simply calls it. That is how you "chain" work together.

The `handle()` signature is entirely up to you — accept whatever arguments make sense, return whatever the caller needs; the package does not constrain it.

To turn a plain class into an action, implement `ActionsPatternInterface` and use the `ActionsPattern` trait. The trait adds a static `make()` factory that resolves the action from Laravel's container (so constructor dependencies are autowired).

Requirements
------------

[](#requirements)

- **PHP 8.3+**
- **Laravel 12+**

The test suite runs against PHP 8.3, 8.4 and 8.5 and Laravel 12 and 13.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require returnearly/actions-pattern
```

Action Class
------------

[](#action-class)

An action is any class that implements `ActionsPatternInterface` and uses the `ActionsPattern` trait:

```
