PHPackages                             pixelcone/fraction - 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. pixelcone/fraction

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

pixelcone/fraction
==================

A set of architecture abstractions to help you build structured and maintainable PHP apps

v0.1.1(2y ago)01.9k[1 issues](https://github.com/pixelcone/fraction/issues)PHPPHP ^8.0

Since Apr 25Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Fraction
========

[](#fraction)

Fraction is a set of abstractions offering PHP devs a convenient way of storing a business logic in their apps.

The idea for this package was born during the process of refactoring a large project written in Laravel. This package was inspired by many different works (packages, articles) of other authors. Here are some of them:

- [Laravel Actions (package)](https://www.laravelactions.com/)
- [Lucid Arch (package)](https://lucidarch.dev/)
- [Laravel AAAS (article)](https://wendelladriel.com/blog/laravel-aaas-actions-as-a-service/#how-to-implement-the-aaas-pattern)

Prerequisites
-------------

[](#prerequisites)

Before you begin, ensure you have met the following requirements:

- PHP ^8.0

There are really no any other requirements. The package is Laravel-friendly, so if you install it into a Laravel project, you will be able to use dependency injection within the `handle()` method of your Actions/Features (more of them down below).

Installing Fraction
-------------------

[](#installing-fraction)

To install Fraction, run the `composer require` command:

```
composer require pixelcone/fraction:^0.1.1
```

Using Fraction
--------------

[](#using-fraction)

This package introduces two abstract layers: Actions and Features.

### Actions

[](#actions)

Actions are basic "Units of Life" of the entire application. In a nutshell, Actions are regular PHP classes, focusing on performing one specific task only (for example, saving a user into DB or sending an email). Actions can accept different parameters via constructor and can be called from anywhere in the code (preferably from Applications or within the same Domain only, though). It is highly recommended to have only one public method in each action class to help developers avoid the temptation of polluting it with extra logic. A name of the Action should reflect what it actually does by answering the question "what should it do?". Actions are parts of Domains, residing in their own `Actions` folder. Actions can also be used as Laravel Jobs.

An example of an Action class and its usage:

```
