Get expert guidance in a few days with a Laravel code review

Laravel Actions

lorisleiva/laravel-actions image

Laravel Actions stats

Downloads
2.2M
Stars
2,201
Open Issues
24
Forks
111

View on GitHub →

Laravel components that take care of one specific task

Laravel Actions Package Summary

The Laravel Actions package offers a streamlined approach to structuring logic in Laravel applications by focusing on distinct actions rather than traditional MVC patterns. This package simplifies development by allowing you to encapsulate application logic into single-action classes that can be executed in various contexts like controllers, jobs, listeners, or commands.

Key Features

  • Single Action Classes: Centralize the logic of specific tasks within single, reusable classes.
  • Flexible Usage: Actions can be run as controllers, jobs, listeners, commands, or even plain objects.
  • Simplifies Code: Reduces the need for separate controllers, form requests, and event listeners by consolidating functionality into action classes.
  • Enhanced Focus: Shifts the development question from structuring based on design patterns to focusing on what the application needs to do.

Installation

Install the package via Composer:

composer require lorisleiva/laravel-actions

Basic Usage

  1. Create an Action: Use Artisan to generate a new action.
    php artisan make:action PublishANewArticle
  2. Define Execution Contexts: Implement methods like asController, asJob, asListener, or asCommand depending on how the action should be used.
  3. Running the Action:
    • As an object: PublishANewArticle::run($author, 'Title', 'Content');
    • As a controller: Register the action in a routes file.
      Route::post('articles', PublishANewArticle::class)->middleware('auth');
    • As a listener: Link the action to an event.
      Event::listen(NewProductReleased::class, PublishANewArticle::class);

Documentation

For detailed documentation on usage and additional features, visit laravelactions.com.

Laravel Actions simplifies application logic management by focusing on what actions your application needs to perform, making it a powerful package for developers looking to streamline their Laravel application development.

lorisleiva photo

Hi there my geeky friends! 👋🦄

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Lorisleiva Laravel Actions Related Articles

Laravel Actions Package image

Laravel Actions Package

Read article
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech