webcartell / anvil
Anvil Container for Apiato.
1.0.0
2025-01-21 20:16 UTC
Requires
- apiato/core: ^v7.0.0
- spatie/laravel-webhook-server: ^3.8
README
A powerful toolkit for Apiato that provides advanced email templating, webhook management, and standardized API patterns.
Features
- 📧 Dynamic Email Template System
- 🔗 Webhook Management
- 🎯 Standardized API Controllers
- 🛠️ Base Task Implementations
- 🔄 Event Dispatching
- 🚀 RPC Action Support
Installation
php composer require webcartell/anvil
Database Setup
Run the migrations to create the necessary tables:
php artisan migrate
This will create:
email_templates
table for managing email templateswebhooks
table for webhook configurations
Core Components
1. Email System
The email system provides a flexible templating solution with:
- Dynamic variable replacement
- Template caching
- Active/inactive template states
- Customizable settings
use App\Containers\Vendor\Anvil\Parents\Mail; class WelcomeEmail extends Mail { protected string $templateName = 'welcome_email'; public function variables(): array { return [ 'user' => [ 'name' => 'John Doe' ] ]; }
2. Webhook Management
Easily manage and trigger webhooks for your API events:
use App\Containers\Vendor\Anvil\Models\Webhook; // Register a webhook Webhook::create([ 'event' => 'user.created', 'url' => 'https://your-endpoint.com/webhook', 'secret_key' => 'your-secret' ]);
3. AnvilController
A powerful base controller that provides:
- Automatic REST action handling
- Event dispatching
- Webhook triggering
- Transformer integration
use App\Containers\Vendor\Anvil\Parents\AnvilController; class UserController extends AnvilController { public bool $dispatchesEvent = true; public bool $triggersWebhooks = true; }
4. AnvilTask
Base task implementation with common database operations:
- Fetch all records
- Find by ID
- Create
- Update
- Delete
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The MIT License (MIT). Please see License File for more information.
Built for Apiato with ❤️