This package provides middleware functionality for handling actions in your Laravel application. Below, you'll find information on how to install, configure.
- Add the package to your composer.json file:
{
"require": {
"ucraft-com/action-middleware": "*"
}
}
And run composer to update your dependencies:
composer update
Or you can simply run
composer require ucraft-com/action-middleware
- Publish the configuration file:
php artisan vendor:publish --tag=action-middleware
-
Configure your middleware settings in the published config/action-middleware.php file.
-
To integrate the Action Middleware Gateway, extend the ActionMiddlewareServiceProvider as shown below:
class ActionMiddlewareServiceProvider extends BaseActionMiddlewareServiceProvider
{
public function getActionMiddlewareGateway(): ActionMiddlewareGatewayInterface
{
$config = config('action-middleware.redis.config');
$setKey = config('action-middleware.redis.setKey')
$connection = (new PhpRedisConnector())->connect($config, []);
return new ActionMiddlewareRedisGateway($connection, $setKey);
}
}
Once installed and configured, you can start using the middleware to handle actions in your application. The default service provider and gateway interfaces provide flexibility for handling various use cases.
Example:
use Uc\ActionMiddleware\ActionMiddlewareRunner;
use Uc\ActionMiddleware\Enums\ActionType;
$result = ActionMiddlewareRunner::run(ActionType::CREATE_CUSTOMER, $request->all(), ['email']);