Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Triggers Laravel Package

caneara/triggers

caneara/triggers extends Laravel’s schema builder with database trigger support, so you can create, modify, and drop triggers directly in migrations using a clean, fluent API. Useful for enforcing data integrity and automating database-side logic.

View on GitHub
Deep Wiki
Context7

A package to add database trigger support to Laravel

Frequently asked questions about Triggers
How do I install caneara/triggers in a Laravel application?
Install it with Composer using composer require caneara/triggers, then use its schema builder extensions inside your Laravel migrations. Confirm the package's composer.json constraints against your Laravel and PHP versions before adopting it. Because it is an early v1.0.x package, test installation in a branch first.
Which Laravel and PHP versions does caneara/triggers support?
The authoritative source is the package's composer.json and release notes, so check those rather than assuming support from the overview. It is a Laravel package installed via Composer, but the exact Laravel and PHP constraints should be verified for your application. Pin the version you validate and avoid floating to untested releases.
Which database engines does caneara/triggers support?
The package generates database trigger SQL, and v1.0.1 removed backticks from that SQL to improve portability. That change alone does not establish tested support for PostgreSQL, SQL Server, or SQLite. Treat it as MySQL-first until you validate the exact engine and version you run in production.
Does caneara/triggers work with PostgreSQL or SQL Server?
There is no clear evidence in the release notes that PostgreSQL or SQL Server are tested targets. Removing backticks may help on engines where backticks are invalid, but trigger body syntax and migration behavior remain database-specific. Run a proof of concept on the exact production engine before relying on it.
Can I create and drop triggers inside Laravel migrations with caneara/triggers?
Yes, the package extends Laravel's schema builder so you can create, modify, and drop triggers in migration up and down methods. Inspect the generated SQL for your database dialect and test migrate and rollback end to end. Also confirm that schema dumps and restores preserve the triggers.
Can I test caneara/triggers against SQLite in CI?
SQLite trigger syntax and behavior differ from MySQL and PostgreSQL, so CI that uses SQLite can mask production differences. Use a production-like database for integration tests that exercise trigger creation, firing, and rollback. Do not rely on SQLite alone to prove trigger behavior.
Is caneara/triggers suitable for audit trails or denormalization?
Triggers are a reasonable fit for narrow database-level guarantees such as audit trails, derived columns, or cross-table invariants that must hold even outside PHP. They are a poor fit for complex workflow logic because they are hidden from normal application flow and harder to test and debug. Keep business logic in PHP and use triggers only where the trade-off is explicit.
What production risks should I consider before using caneara/triggers?
Managed databases may restrict trigger creation or require specific ownership and permissions. Trigger logic can also cause write failures or lock contention under load, and rollback and drop behavior must be proven. Test under realistic write load in staging and document ownership and removal steps.
Is caneara/triggers actively maintained and safe to depend on?
This is an early-stage v1.0.x package with limited release history, so pin the version you validate and monitor upstream releases. Treat trigger definitions as production code and review them like application logic. Assign an internal owner for trigger SQL and rollback procedures.
What are alternatives to caneara/triggers for Laravel?
Alternatives include writing raw CREATE TRIGGER statements in migrations, using application-level events and services, or adopting a dedicated audit or history package. Choose based on whether you need a database-level guarantee or just application-side automation. If you need portability, validate any trigger approach against each target database.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource