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
Typesense Search logo

Typesense Search

Typesense is an open source, blazing-fast search engine, optimized for helping you build delightful search experiences for your sites and apps. Natively integrated with Laravel Scout.

Typesense Search
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
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
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
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
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