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
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
Statamic logo

Statamic

The drop-in ready Laravel CMS you’re been waiting for. Go full-stack or headless, flat file or database – it’s up to you.

Statamic
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
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
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
Tinkerwell logo

Tinkerwell

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

Tinkerwell