PHPackages                             zachflower/eloquent-interactions - 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. [Database &amp; ORM](/categories/database)
4. /
5. zachflower/eloquent-interactions

ActiveLibrary[Database &amp; ORM](/categories/database)

zachflower/eloquent-interactions
================================

An implementation of the interactor pattern for Laravel.

v1.0.0(2y ago)1312.3k3MITPHPPHP ^7.2.5|^8.0

Since Mar 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/zachflower/eloquent-interactions)[ Packagist](https://packagist.org/packages/zachflower/eloquent-interactions)[ RSS](/packages/zachflower-eloquent-interactions/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (7)Versions (7)Used By (0)

Eloquent Interactions
=====================

[](#eloquent-interactions)

Eloquent Interactions manages application-specific business logic. It's an implementation of the [command pattern](https://refactoring.guru/design-patterns/command) in PHP for Laravel, and is inspired by the [ActiveInteraction](https://github.com/AaronLasseigne/active_interaction) library in Ruby.

[![Latest Stable Version](https://camo.githubusercontent.com/c169c2dd28025fa4d7bbd0363e8126fc35303b6e60259fa054780c586903e3db/68747470733a2f2f706f7365722e707567782e6f72672f7a616368666c6f7765722f656c6f7175656e742d696e746572616374696f6e732f76657273696f6e)](https://packagist.org/packages/zachflower/eloquent-interactions) [![CI](https://github.com/zachflower/eloquent-interactions/actions/workflows/main.yml/badge.svg)](https://github.com/zachflower/eloquent-interactions/actions/workflows/main.yml)

---

Eloquent Interactions gives you a place to put your business logic. It also helps you write safer code by validating that your inputs conform to your expectations, and provides a platform for creating discrete, easily testable code.

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

[](#installation)

To install Eloquent Interactions, require the library via [Composer](https://getcomposer.org/):

```
composer require zachflower/eloquent-interactions

```

Eloquent Interactions is built with Laravel 7.0+ in mind, and has tests currently validating compatibility with Laravel 7, 8, 9, and 10 on PHP 7.2.5 through 8.3. If you find any issues with your specific version of Laravel or PHP, please [open an issue](https://github.com/zachflower/eloquent-interactions/issues/new) and I will do my best to address it.

Basic Usage
-----------

[](#basic-usage)

To get started with Eloquent Interactions, let's first create a new Interaction. Interactions typically live in the `app/Interactions` directory, but you are free to place them anywhere that can be auto-loaded according to your `composer.json` file. All Eloquent Interactions extend the `\ZachFlower\EloquentInteractions\Interaction` abstract class.

The easiest way to create an Interaction is using the `make:interaction` [Artisan command](https://laravel.com/docs/master/artisan):

```
php artisan make:interaction ConvertMetersToMiles

```

Now, let's take a look at the base Interaction that was created by the `make:interaction` command above:

```
