Download the PHP package edulazaro/laractions without Composer

On this page you can find all versions of the php package edulazaro/laractions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laractions

Laractions - Actions for Laravel

Tests Latest Stable Version Total Downloads PHP Version License

Encapsulate your business logic into clean, reusable classes that run synchronously or asynchronously in Laravel.

Introduction

Laractions is a package that introduces an action-based pattern for Laravel applications. Actions encapsulate specific pieces of logic that can be executed synchronously or asynchronously, keeping your controllers and models clean.

Instead of placing business logic in controllers, models, or services, actions allow you to encapsulate reusable operations in self-contained classes.

Supports Standalone & Model-Scoped Actions
Allows Asynchronous Execution with Queues
Provides an Artisan Generator for Quick Creation

Why Use Actions?

Instead of bloating controllers, models, or services, Laractions keeps logic encapsulated and reusable.

Feature Laractions
Encapsulation Keeps business logic clean & reusable
Async Execution Supports Laravel queues & retries
Validation Auto-validates parameters before execution
Model-bound Works directly with Eloquent models
Fluent API run(), dispatch(), retry(), queue()

Installation

Laractions requires PHP 8.2+ and Laravel 11+. Install via Composer:

Once installed, the package will be available in your Laravel application: the service provider is auto discovered and there is nothing to publish to start writing actions.

Naming

Name the class whatever you want to read at the call site. make:action uses the name you give it, unchanged:

Both conventions are in use. SendEmail reads well because the App\Actions\* namespace already carries the intent, the way Laravel writes App\Jobs\SendEmail rather than SendEmailJob. SendEmailAction reads well because the suffix survives the import, and at the call site you can tell an action from a model without looking it up. Pick one and keep it.

Creating Actions

You can manually create an action or use the artisan command:

This will generate this basic action:

You will place the logic inside the handle method:

You can then run the action via the run method:

How run() maps arguments to handle()

run() forwards its arguments to handle() by reflection. You can call it in three ways:

When handle() declares more than one parameter, the keys of an associative array are matched to the parameter names (the last example above).

When handle() declares a single array (or iterable/mixed/untyped) parameter, the array is passed through whole as that one argument — the "attribute bag" pattern:

When the single parameter is a concrete type (an object or scalar, e.g. handle(File $file)), a single array is not treated as the bag: its keys are mapped by name, and a single value is passed positionally — so both of these bind $file:

This mirrors native PHP: an array parameter receives the array whole, while a typed parameter receives the matching value, never the wrapping array. (A union that includes array/iterable — e.g. array|Foo — still receives the bag.)

You can customize the constructor. Dependencies will be injected:

You can run the action as usually via the run method:

Creating Model Actions

You can manually create a model action or use the artisan command:

This will create the next basic model action:

The user instance will be available inside the $user attribute.

Models using actios should use the HasActions trait, so you can register actions inside the $actions array of the model:

Now, you can execute the action using:

Alternatively, you can still call the action class directly so you don't have to define the action inside the model:

Dynamic Parameters

Laractions provides a flexible with() method to set action attributes dynamically:

This avoids passing long parameter lists in the run() method. Please note that these values will be set as action attributes, so you would access them via:

Actions and Models

When calling an action from a model, the model is automatically injected into the action:

If the SendEmail class has a $user property, the action will automatically set the model:

Running Actions Asynchronously

Laractions allows dispatching actions asynchronously as jobs:

This queues the action instead of executing it immediately. The job will be automatically created and liked to the action, so you don't need to define it.

You can configure how actions are dispatched as jobs:

Mocking Actions for Tests

During unit tests, you can mock actions:

This allows testing without executing real logic.

List Available Actions

To list all registered actions in your application, run:

Logging Actions

Enable logging for any action:

Logs will be written to Laravel's log files.

Acting as an Actor

You can make any model an actor (like a User) by using the IsActor trait:

Then, call actions like this:

This automatically sets the actor on the action before executing it.

Enabling Tracing

Tracing is disabled by default. You can enable it per action like this:

You can assign the actor and actionable model like so:

Here is an traced action started by an actor:

LaraClaude integration

Laractions is supported by LaraClaude, a Laravel toolkit plugin for Claude Code. It ships two skills that work with your actions:

Both skills read the installed Laractions API so they only use what your version actually has, match the conventions of your existing actions, and run a syntax check on the generated class.

Install the plugin in Claude Code with /plugin install github:edulazaro/laraclaude.

Sponsors

Laractions is supported by the following sponsors. Thank you for keeping it growing:

Kenodo     AndorraDev

Author

Created by Edu Lazaro

License

Laractions is open-sourced software licensed under the MIT license.


All versions of laractions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version >=11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package edulazaro/laractions contains the following files

Loading the files please wait ...