Download the PHP package attia-ahmed/extendable-action without Composer
On this page you can find all versions of the php package attia-ahmed/extendable-action. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download attia-ahmed/extendable-action
More information about attia-ahmed/extendable-action
Files in attia-ahmed/extendable-action
Package extendable-action
Short Description An Abstract classes to make extendable actions for the Laravel framework.
License Apache-2.0
Informations about the package extendable-action
ExtendableAction
Laravel packages that allows you to make your laravel project extendable and easy to include new features without touching old code throgh Extendable Actions .
Why ExtendableAction?
Having a large codebase and dynamic features leads to a missy codebase with huge maintainability headache! This package implements the main concept of WordPress pluggable features by using of Filters and Actions ( See WordPress Hooks ) that allow you to expand your codebase in a pluggable way.
Installation
- Install via composer
or add it by hand to your composer.json
file.
-
Publish the config file with:
- Append to your in
app.php
config file :
Usage
- make your extendable action:
Which is the main functionality that needs to be extended. You can make your extendable action by
extending ExtendableAction
class and define the method that take any number of parameters (will be modified
by filters) and return result (will be modified by actions) then it will be called as Invokable Class Example:
- make your filters:
Which are classes that modifies the ExtendableAction
input parameters or do some logic/check before running the main
functionality. You can make your Filter by extending Filter
class and override the method that
takes method parameters of ExtendableAction
as an array and returns array of parameters to be modified with
another filters or to be passed to main ExtendableAction
Example:
- make your actions:
Which are classes that modifies the ExtendableAction
result or do some logic/check after running the main
functionality. You can make your Action by extending Action
class and override the method that takes the
result of method of ExtendableAction
and returns new result to be modified with another actions or to be
final return result of ExtendableAction
functionality. Example:
- Link your Filters and Actions to your Extendable action :
You can link your Filters and Action to your Extendable Action by adding new element
in ExtendableActionAppServiceProvider
protected attribute
or by your custom implementation by overriding and of class
Example :
-
Call your Extendable action :
is an Invokable Class and can be called by as one of following examples:
or
Compatibility with other packages
spatie/laravel-queueable-action:
you can use Extendable Action with Queueable Actions as following:
- Extend your Queueable Action from
- Add your code logic in custom defined method (Do Not Override __invoke() method)
- call your Queuable action as normal and Extend it with any Filters or Actions 🎉
note: You should return result to be returned to your Actions attached to Extendable Action
All your Filters and Action will run in queue
Examle:
Queuable Extendable Action: