tastyigniter/ti-ext-automation
Automate TastyIgniter tasks with scheduled workflows and event-based rules. Trigger actions like order updates, customer notifications, and system maintenance automatically, reducing manual work and improving operational consistency.
Installation Add the package via Composer:
composer require tastyigniter/ti-ext-automation
Publish the config file (if needed):
php artisan vendor:publish --provider="TastyIgniter\TiExtAutomation\TiExtAutomationServiceProvider" --tag="config"
Basic Setup
Register an automation rule in config/ti-ext-automation.php:
'rules' => [
'user_created' => [
'trigger' => 'user.created',
'actions' => [
'send_welcome_email',
'log_activity',
],
],
],
Define actions in a service provider (e.g., AppServiceProvider):
public function boot()
{
TiExtAutomation::action('send_welcome_email', function ($user) {
Mail::to($user->email)->send(new WelcomeEmail($user));
});
}
First Use Case Trigger an automation when a user registers:
event(new Registered($user)); // Laravel's default event
// Automatically triggers 'user.created' rule and its actions.
Event-Driven Triggers
user.created, order.placed) or custom events.TiExtAutomation::trigger('user.created', ['user' => $user]);
Conditional Actions
TiExtAutomation::action('notify_admin_if_premium', function ($user) {
if ($user->isPremium()) {
Notification::send(new AdminAlert($user));
}
});
Queueing Actions
TiExtAutomation::action('process_payment', function ($order) {
ProcessPaymentJob::dispatch($order);
});
Dynamic Rule Loading
$rules = RuleRepository::fetchDynamicRules();
TiExtAutomation::loadRules($rules);
Integration with Observers
User::observe(UserAutomationObserver::class);
class UserAutomationObserver {
public function created(User $user) {
TiExtAutomation::trigger('user.created', ['user' => $user]);
}
}
Circular Dependencies
send_email → log_email_sent → send_email).triggered flag or queue delays.Missing Dependencies
boot() method.Performance Overhead
dispatch()) for non-critical actions.Config Overrides
config/ti-ext-automation.php are merged with dynamic rules. Unexpected behavior may occur if keys clash.user.created.v1).Log Triggers: Enable debug logging in the config:
'debug' => true,
Check storage/logs/laravel.log for triggered actions.
Validate Rules: Use Artisan command to validate rules:
php artisan ti-automation:validate
Test Incrementally: Start with one rule/action, then expand. Example:
TiExtAutomation::trigger('test_rule', ['data' => 'test']);
Custom Triggers
Extend the trigger system by implementing TastyIgniter\TiExtAutomation\Contracts\Triggerable:
class CustomTrigger implements Triggerable {
public function trigger(string $rule, array $data) {
// Custom logic (e.g., API call)
}
}
Action Middleware Add middleware to actions:
TiExtAutomation::action('send_email')
->middleware(Throttle::class)
->execute(function ($user) {
// ...
});
Rule Validation
Add validation to rules using Laravel’s Validator:
TiExtAutomation::rule('user_created')
->validate(function ($data) {
return Validator::make($data, ['user.email' => 'required|email']);
});
How can I help you explore Laravel packages today?