PHPackages                             matheus-rosa/php-interactor - 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. matheus-rosa/php-interactor

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

matheus-rosa/php-interactor
===========================

A single purpose object library built for PHP

1.0.0(2y ago)19PHPPHP &gt;=5.4

Since Jul 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/matheus-rosa/php-interactor)[ Packagist](https://packagist.org/packages/matheus-rosa/php-interactor)[ RSS](/packages/matheus-rosa-php-interactor/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

php-interactor
==============

[](#php-interactor)

A single purpose object library built for PHP. Heavily inspired by the [interactor](https://github.com/collectiveidea/interactor) gem for Ruby.

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

[](#requirements)

- PHP &gt;= 5.6

What is an Interactor?
----------------------

[](#what-is-an-interactor)

An Interactor is, in simple words, a single purpose object. That means a class having a single responsibility according to what SOLID principles describes. An Interactor usually represents an action, such as *SaveUser*, *BuildAttributes*, *GetExternalAPIResource* and so forth. A *SaveUser* interactor would only literally mean saving a user record in some storage (a database, for instance) therefore it won't be responsible for doing anything else.

OK, but why is a big deal to use it?
------------------------------------

[](#ok-but-why-is-a-big-deal-to-use-it)

You may be asking yourself why this library is relevant to you. Of course, you can go ahead and start creating your own single-purpose object implementation though we all know that not establishing a well-designed pattern in the very beginning of a development cycle can result in totally chaos where everybody does whatever they want without a pattern. Plus, why reinvent the wheel whilst someone has done the heavy job for you?

By giving a chance to this library you will find yourself creating straight forward and maintainable services while adopting a conventional pattern among them. I assure you that you will save some considerable time. Give it a shot! :)

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

[](#installation)

```
composer require matheus-rosa/php-interactor
```

Creating your first Interactor
------------------------------

[](#creating-your-first-interactor)

Say we're about to create a component responsible for saving a `User` model record:

```
