PHPackages                             stagerightlabs/actions - 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. stagerightlabs/actions

ActiveLibrary

stagerightlabs/actions
======================

Action classes for handling discrete units of business logic.

0.00.41(4y ago)1533[1 issues](https://github.com/stagerightlabs/actions/issues)MITPHPPHP ^7.3 || ^8.0

Since Oct 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/stagerightlabs/actions)[ Packagist](https://packagist.org/packages/stagerightlabs/actions)[ RSS](/packages/stagerightlabs-actions/feed)WikiDiscussions dev Synced 1w ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

[![Discrete units of logic for PHP](https://camo.githubusercontent.com/c3fb4881b58160a5253e1f87d83939fe20ebddb45678c4455e4849d3f9d7076a/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f416374696f6e732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d737461676572696768746c616273253246616374696f6e73267061747465726e3d666c6f6174696e67436f6773267374796c653d7374796c655f31266465736372697074696f6e3d44697363726574652b756e6974732b6f662b6c6f6769632b666f722b504850266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d6265616b6572)](https://camo.githubusercontent.com/c3fb4881b58160a5253e1f87d83939fe20ebddb45678c4455e4849d3f9d7076a/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f416374696f6e732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d737461676572696768746c616273253246616374696f6e73267061747465726e3d666c6f6174696e67436f6773267374796c653d7374796c655f31266465736372697074696f6e3d44697363726574652b756e6974732b6f662b6c6f6769632b666f722b504850266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d6265616b6572)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9054526debbf0cb6fd127862e7f4c69ee28a84920f834022b3590c38baab01d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737461676572696768746c6162732f616374696f6e732e7376673f7374796c653d666c6174)](https://packagist.org/packages/stagerightlabs/actions)[![Total Downloads](https://camo.githubusercontent.com/12f0402527f69b66b23b7a3e9fdb1377e2385ecb1f43d296ca6517bbac7ad78d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737461676572696768746c6162732f616374696f6e732e7376673f7374796c653d666c6174)](https://packagist.org/packages/stagerightlabs/actions)[![Tests](https://github.com/stagerightlabs/actions/actions/workflows/ci.yml/badge.svg)](https://github.com/stagerightlabs/actions/actions/workflows/ci.yml)

Actions
=======

[](#actions)

Action classes are a pattern for isolating business logic from the rest of an application. This makes it easier to test the business logic and it provides portability: you can use the same action class in multiple contexts which helps to DRY up your codebase.

This package provides a foundation for creating action classes that will integrate easily with the rest of your PHP application.

Inspiration
-----------

[](#inspiration)

This idea has been in the back of my mind for some time. However, these blog posts really helped me shape my ideas about how Action classes should work and inspired me to create this package:

- [Brent Roose - Actions](https://stitcher.io/blog/laravel-beyond-crud-03-actions)
- [Brent Roose - Domain Oriented Laravel](https://stitcher.io/blog/laravel-beyond-crud-01-domain-oriented-laravel)
- [Freek Van der Herten - Refactoring to Actions](https://freek.dev/1371-refactoring-to-actions)

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

[](#installation)

Install this library with [Composer](https://getcomposer.org/):

```
$ composer require stagerightlabs/actions

```

Instructions
------------

[](#instructions)

This library provides an abstract `Action` class that you can extend to create your own action classes. All you need to do is provide a `handle` method which contains your business logic. For example:

```
