1. Go to this page and download the library: Download talleu/trigger-mapping library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
talleu / trigger-mapping example snippets
namespace App\Entity;
use Talleu\TriggerMapping\Attribute\Trigger;
use App\Triggers\UpdateUserTimestamp;
#[ORM\Entity]
#[Trigger(
name: 'trg_user_updated_at',
function: 'fn_update_timestamp',
on: ['INSERT', 'UPDATE'],
when: 'BEFORE',
scope: 'ROW',
className: UpdateUserTimestamp::class,
)]
class User { /* ... */ }
use Talleu\TriggerMapping\Attribute\Trigger;
#[ORM\Entity]
#[Trigger(
name: 'trg_audit_user', // SQL identifier ( // INSERT, UPDATE, DELETE, TRUNCATE (PG-only)
when: 'BEFORE', // BEFORE, AFTER, INSTEAD OF
scope: 'ROW', // ROW, STATEMENT
storage: 'php', // (optional) override the global storage type for this trigger
className: UserAuditTrigger::class, // (optional) FQCN of the PHP trigger class
onTable: 'user_role', // (optional) explicit table name, e.g. for ManyToMany join tables
)]
class User { /* ... */ }
#[Trigger(name: 'trg_log_insert', on: ['INSERT'], when: 'AFTER', scope: 'ROW')]
#[Trigger(name: 'trg_log_update', on: ['UPDATE'], when: 'AFTER', scope: 'ROW')]
class User { /* ... */ }
// Auto-generated Version20260101000000.php (excerpt)
public function up(Schema $schema): void
{
$this->addSql(\App\Triggers\TrgUserUpdatedAt::getFunction());
$this->addSql(\App\Triggers\TrgUserUpdatedAt::getTrigger());
}
public function down(Schema $schema): void
{
$this->addSql('DROP TRIGGER IF EXISTS trg_user_updated_at ON user;');
$this->addSql('DROP FUNCTION IF EXISTS fn_update_timestamp();');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.