Conditional Audit Logging
Created a Symfony AuditTrailBundle that supports declarative audit conditions. Use expressions like
https://preview.redd.it/f6wuj10ycyag1.png?width=871&format=png&auto=webp&s=af315f2d5dee8ffc15f55eb78f05945438c1d645
https://redd.it/1q215l5
@r_php
Created a Symfony AuditTrailBundle that supports declarative audit conditions. Use expressions like
#[AuditCondition("action == 'update' and object.getPrice() > 100")] to control exactly when entities are audited. No more logging everything and filtering later.https://preview.redd.it/f6wuj10ycyag1.png?width=871&format=png&auto=webp&s=af315f2d5dee8ffc15f55eb78f05945438c1d645
https://redd.it/1q215l5
@r_php
GitHub
GitHub - rcsofttech85/AuditTrailBundle: A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine…
A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine ORM entity changes for audit logging and compliance. - rcsofttech85/AuditTrailBundle
Tiny PHP pretty-printer that formats arrays like PyTorch tensors
I’ve released a small helper for anyone working with PHP + data-heavy code (ML experiments, debugging, logs, educational projects, etc.).
PrettyPrint is a zero-dependency callable pretty-printer for PHP arrays with clean, Python-style formatting. It supports aligned 2D tables, PyTorch-like tensor views, summarization (head/tail rows & columns), and works both in CLI and web contexts.
Install:
composer require apphp/pretty-print
Examples:
Aligned 2D table:
pprint(1, 23, 456, 12, 3, 45);
// [ 1, 23, 456,
// 12, 3, 45]
PyTorch-style 2D output:
pprint($matrix);
// tensor(
// [ 1, 2, 3, 4, 5,
// 6, 7, 8, 9, 10,
// 11, 12, 13, 14, 15
// ])
Summaries for big matrices:
pprint($m, headRows: 2, tailRows: 1, headCols: 2, tailCols: 2);
3D tensors with ellipsis:
pprint($tensor3d, headB: 1, tailB: 1);
// tensor(
// [ 1, 2, ..., 4, 5,
// 6, 7, ..., 9, 10,
// ...,
// 21, 22, ..., 24, 25
// ])
Also supports labels, precision, start/end strings, and even acts as a callable object:
$pp = new PrettyPrint();
$pp('Hello', 42);
// Hello 42
You may find much more information in repo: *https://github.com/apphp/pretty-print*
If you often stare at messy
https://redd.it/1q2cu1w
@r_php
I’ve released a small helper for anyone working with PHP + data-heavy code (ML experiments, debugging, logs, educational projects, etc.).
PrettyPrint is a zero-dependency callable pretty-printer for PHP arrays with clean, Python-style formatting. It supports aligned 2D tables, PyTorch-like tensor views, summarization (head/tail rows & columns), and works both in CLI and web contexts.
Install:
composer require apphp/pretty-print
Examples:
Aligned 2D table:
pprint(1, 23, 456, 12, 3, 45);
// [ 1, 23, 456,
// 12, 3, 45]
PyTorch-style 2D output:
pprint($matrix);
// tensor(
// [ 1, 2, 3, 4, 5,
// 6, 7, 8, 9, 10,
// 11, 12, 13, 14, 15
// ])
Summaries for big matrices:
pprint($m, headRows: 2, tailRows: 1, headCols: 2, tailCols: 2);
3D tensors with ellipsis:
pprint($tensor3d, headB: 1, tailB: 1);
// tensor(
// [ 1, 2, ..., 4, 5,
// 6, 7, ..., 9, 10,
// ...,
// 21, 22, ..., 24, 25
// ])
Also supports labels, precision, start/end strings, and even acts as a callable object:
$pp = new PrettyPrint();
$pp('Hello', 42);
// Hello 42
You may find much more information in repo: *https://github.com/apphp/pretty-print*
If you often stare at messy
print_r() dumps to print arrays, this might make your day slightly better 😄https://redd.it/1q2cu1w
@r_php
GitHub
GitHub - apphp/pretty-print: PrettyPrint is a small, zero-dependency PHP utility that formats arrays in a clean, readable, PyTorch…
PrettyPrint is a small, zero-dependency PHP utility that formats arrays in a clean, readable, PyTorch-inspired style. It supports aligned 2D tables, 3D tensors, summarized tensor views, and flexibl...
Kreuzberg.dev now has PHP bindings (open-source document processing engine)
Hi all,
We’ve added PHP bindings for Kreuzberg.dev, an open-source document processing engine with a fast Rust core.
That means Kreuzberg now supports most major backend languages:Rust, Python, Ruby, Go, PHP, Elixir, and TypeScript/Node.js
Kreuzberg is an MIT-licensed framework for extracting and structuring data from 50+ documents formats (PDFs, Office, images, emails, etc.). Repo: https://github.com/kreuzberg-dev/kreuzberg
Your feedback, thoughts, and contributions are very welcome. Have a great start to 2026!
https://redd.it/1q2ojco
@r_php
Hi all,
We’ve added PHP bindings for Kreuzberg.dev, an open-source document processing engine with a fast Rust core.
That means Kreuzberg now supports most major backend languages:Rust, Python, Ruby, Go, PHP, Elixir, and TypeScript/Node.js
Kreuzberg is an MIT-licensed framework for extracting and structuring data from 50+ documents formats (PDFs, Office, images, emails, etc.). Repo: https://github.com/kreuzberg-dev/kreuzberg
Your feedback, thoughts, and contributions are very welcome. Have a great start to 2026!
https://redd.it/1q2ojco
@r_php
GitHub
GitHub - kreuzberg-dev/kreuzberg: A polyglot document intelligence framework with a Rust core. Extract text, metadata, and structured…
A polyglot document intelligence framework with a Rust core. Extract text, metadata, and structured information from PDFs, Office documents, images, and 50+ formats. Available for Rust, Python, Rub...
Kreuzberg.dev now has PHP bindings (open-source document processing engine)
Hi all,
We’ve added PHP bindings for Kreuzberg.dev, an open-source document processing engine with a fast Rust core.
That means Kreuzberg now supports most major backend languages: Rust, Python, Ruby, Go, Java, C#, PHP, Elixir, and TypeScript/Node.js
Kreuzberg is an MIT-licensed framework for extracting and structuring data from 50+ documents formats (PDFs, Office, images, emails, etc.).
Repo: https://github.com/kreuzberg-dev/kreuzberg
Your feedback, thoughts, and contributions are very welcome. Have a great start to 2026!
https://redd.it/1q2ojco
@r_php
Hi all,
We’ve added PHP bindings for Kreuzberg.dev, an open-source document processing engine with a fast Rust core.
That means Kreuzberg now supports most major backend languages: Rust, Python, Ruby, Go, Java, C#, PHP, Elixir, and TypeScript/Node.js
Kreuzberg is an MIT-licensed framework for extracting and structuring data from 50+ documents formats (PDFs, Office, images, emails, etc.).
Repo: https://github.com/kreuzberg-dev/kreuzberg
Your feedback, thoughts, and contributions are very welcome. Have a great start to 2026!
https://redd.it/1q2ojco
@r_php
GitHub
GitHub - kreuzberg-dev/kreuzberg: A polyglot document intelligence framework with a Rust core. Extract text, metadata, and structured…
A polyglot document intelligence framework with a Rust core. Extract text, metadata, and structured information from PDFs, Office documents, images, and 50+ formats. Available for Rust, Python, Rub...
Capture Impersonated User Details and Add Custom Context - AuditTrailBundle
Enhances audit logging by capturing impersonated user information and attaching additional custom context to each log entry. This ensures better traceability, clearer accountability, and improved debugging for actions performed under user impersonation.
https://preview.redd.it/t3nyypd8n5bg1.png?width=881&format=png&auto=webp&s=42bafa8adeb0fc3dd920a94142cb2f007bfd448c
https://redd.it/1q2xstk
@r_php
Enhances audit logging by capturing impersonated user information and attaching additional custom context to each log entry. This ensures better traceability, clearer accountability, and improved debugging for actions performed under user impersonation.
https://preview.redd.it/t3nyypd8n5bg1.png?width=881&format=png&auto=webp&s=42bafa8adeb0fc3dd920a94142cb2f007bfd448c
https://redd.it/1q2xstk
@r_php
GitHub
GitHub - rcsofttech85/AuditTrailBundle: A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine…
A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine ORM entity changes for audit logging and compliance. - rcsofttech85/AuditTrailBundle
Sunsetting Enlightn
2 months ago, u/ShadowSpade wondered what happened to Enlightn, this week I received this email:
>Sunsetting Enlightn
>After much thought and consideration, we are sunsetting Enlightn. It will be shutting down starting Jan 2026. With rapid advances in AI powered code assistants, it has become clear that they now cover most of the use cases Enlightn was built for.
>Recently purchased licenses have been fully refunded. Feel free to email us at sales at laravel-enlightn dot com for any questions or refund requests if we missed on refunding your recently purchased license. The open source package on Github will stay available for anyone who finds it useful. Thank you for the support and for trusting Enlightn to help improve your apps over the years!
https://redd.it/1q1tal9
@r_php
2 months ago, u/ShadowSpade wondered what happened to Enlightn, this week I received this email:
>Sunsetting Enlightn
>After much thought and consideration, we are sunsetting Enlightn. It will be shutting down starting Jan 2026. With rapid advances in AI powered code assistants, it has become clear that they now cover most of the use cases Enlightn was built for.
>Recently purchased licenses have been fully refunded. Feel free to email us at sales at laravel-enlightn dot com for any questions or refund requests if we missed on refunding your recently purchased license. The open source package on Github will stay available for anyone who finds it useful. Thank you for the support and for trusting Enlightn to help improve your apps over the years!
https://redd.it/1q1tal9
@r_php
Reddit
From the laravel community on Reddit
Explore this post and more from the laravel community
Env-Interop Now Open For Public Review
https://pmjones.io/post/2026/01/03/env-interop-now-open-for-public-review/
https://redd.it/1q2zmk1
@r_php
https://pmjones.io/post/2026/01/03/env-interop-now-open-for-public-review/
https://redd.it/1q2zmk1
@r_php
Conditional Audit Logging
Created a Symfony AuditTrailBundle that supports declarative audit conditions. Use expressions like
https://preview.redd.it/f6wuj10ycyag1.png?width=871&format=png&auto=webp&s=af315f2d5dee8ffc15f55eb78f05945438c1d645
https://redd.it/1q215l5
@r_php
Created a Symfony AuditTrailBundle that supports declarative audit conditions. Use expressions like
#[AuditCondition("action == 'update' and object.getPrice() > 100")] to control exactly when entities are audited. No more logging everything and filtering later.https://preview.redd.it/f6wuj10ycyag1.png?width=871&format=png&auto=webp&s=af315f2d5dee8ffc15f55eb78f05945438c1d645
https://redd.it/1q215l5
@r_php
GitHub
GitHub - rcsofttech85/AuditTrailBundle: A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine…
A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine ORM entity changes for audit logging and compliance. - rcsofttech85/AuditTrailBundle
Musings and realizations from 2025 as a Laravel developer
https://cosmastech.com/2026/01/01/musings.html
https://redd.it/1q17w2j
@r_php
https://cosmastech.com/2026/01/01/musings.html
https://redd.it/1q17w2j
@r_php
cosmastech
Musings on 2025
As 2025 wraps up, I wanted to touch on some broader topics that I thought deeply about this year.
Laravel Gems: Advanced Patterns & Architecture Beyond Controllers
I’ve been building Laravel applications for 10+ years and still genuinely love the framework, its documentation, and the community.
I’d like to start a thread compiling “gems” — talks, videos, or resources that highlight useful patterns, architectural ideas, and techniques that go beyond the usual controller / model / service approach.
Here are some of my favourite videos to kick things off. I’d love to see what resources have influenced the way you structure Laravel apps 👇
Manager pattern: [https://www.youtube.com/watch?v=jCJ\_dxAlHdo&list=PLSfH3ojgWsQopTurfF8lKNAgwtb1XzSMg&index=11](https://www.youtube.com/watch?v=jCJ_dxAlHdo&list=PLSfH3ojgWsQopTurfF8lKNAgwtb1XzSMg&index=11)
Pipeline pattern: https://www.youtube.com/watch?v=2REc-Wlvl9M
State machines: [https://www.youtube.com/watch?v=1A1xFtlDyzU&t](https://www.youtube.com/watch?v=1A1xFtlDyzU&t)
Value objects: https://www.youtube.com/watch?v=0jRTq0Hy\_50
Macros: [https://www.youtube.com/watch?v=G78sN4\_KEdU](https://www.youtube.com/watch?v=G78sN4_KEdU)
Service container + DI: https://www.youtube.com/watch?v=y7EbrV4ChJs
https://redd.it/1q35mne
@r_php
I’ve been building Laravel applications for 10+ years and still genuinely love the framework, its documentation, and the community.
I’d like to start a thread compiling “gems” — talks, videos, or resources that highlight useful patterns, architectural ideas, and techniques that go beyond the usual controller / model / service approach.
Here are some of my favourite videos to kick things off. I’d love to see what resources have influenced the way you structure Laravel apps 👇
Manager pattern: [https://www.youtube.com/watch?v=jCJ\_dxAlHdo&list=PLSfH3ojgWsQopTurfF8lKNAgwtb1XzSMg&index=11](https://www.youtube.com/watch?v=jCJ_dxAlHdo&list=PLSfH3ojgWsQopTurfF8lKNAgwtb1XzSMg&index=11)
Pipeline pattern: https://www.youtube.com/watch?v=2REc-Wlvl9M
State machines: [https://www.youtube.com/watch?v=1A1xFtlDyzU&t](https://www.youtube.com/watch?v=1A1xFtlDyzU&t)
Value objects: https://www.youtube.com/watch?v=0jRTq0Hy\_50
Macros: [https://www.youtube.com/watch?v=G78sN4\_KEdU](https://www.youtube.com/watch?v=G78sN4_KEdU)
Service container + DI: https://www.youtube.com/watch?v=y7EbrV4ChJs
https://redd.it/1q35mne
@r_php
Tiny PHP pretty-printer that formats arrays like PyTorch tensors
I’ve released a small helper for anyone working with PHP + data-heavy code (ML experiments, debugging, logs, educational projects, etc.).
PrettyPrint is a zero-dependency callable pretty-printer for PHP arrays with clean, Python-style formatting. It supports aligned 2D tables, PyTorch-like tensor views, summarization (head/tail rows & columns), and works both in CLI and web contexts.
Install:
composer require apphp/pretty-print
Examples:
Aligned 2D table:
pprint(1, 23, 456, 12, 3, 45);
// [ 1, 23, 456,
// 12, 3, 45]
PyTorch-style 2D output:
pprint($matrix);
// tensor(
// [ 1, 2, 3, 4, 5,
// 6, 7, 8, 9, 10,
// 11, 12, 13, 14, 15
// ])
Summaries for big matrices:
pprint($m, headRows: 2, tailRows: 1, headCols: 2, tailCols: 2);
3D tensors with ellipsis:
pprint($tensor3d, headB: 1, tailB: 1);
// tensor(
// [ 1, 2, ..., 4, 5,
// 6, 7, ..., 9, 10,
// ...,
// 21, 22, ..., 24, 25
// ])
Also supports labels, precision, start/end strings, and even acts as a callable object:
$pp = new PrettyPrint();
$pp('Hello', 42);
// Hello 42
You may find much more information in repo: *https://github.com/apphp/pretty-print*
If you often stare at messy
https://redd.it/1q2cu1w
@r_php
I’ve released a small helper for anyone working with PHP + data-heavy code (ML experiments, debugging, logs, educational projects, etc.).
PrettyPrint is a zero-dependency callable pretty-printer for PHP arrays with clean, Python-style formatting. It supports aligned 2D tables, PyTorch-like tensor views, summarization (head/tail rows & columns), and works both in CLI and web contexts.
Install:
composer require apphp/pretty-print
Examples:
Aligned 2D table:
pprint(1, 23, 456, 12, 3, 45);
// [ 1, 23, 456,
// 12, 3, 45]
PyTorch-style 2D output:
pprint($matrix);
// tensor(
// [ 1, 2, 3, 4, 5,
// 6, 7, 8, 9, 10,
// 11, 12, 13, 14, 15
// ])
Summaries for big matrices:
pprint($m, headRows: 2, tailRows: 1, headCols: 2, tailCols: 2);
3D tensors with ellipsis:
pprint($tensor3d, headB: 1, tailB: 1);
// tensor(
// [ 1, 2, ..., 4, 5,
// 6, 7, ..., 9, 10,
// ...,
// 21, 22, ..., 24, 25
// ])
Also supports labels, precision, start/end strings, and even acts as a callable object:
$pp = new PrettyPrint();
$pp('Hello', 42);
// Hello 42
You may find much more information in repo: *https://github.com/apphp/pretty-print*
If you often stare at messy
print_r() dumps to print arrays, this might make your day slightly better 😄https://redd.it/1q2cu1w
@r_php
GitHub
GitHub - apphp/pretty-print: PrettyPrint is a small, zero-dependency PHP utility that formats arrays in a clean, readable, PyTorch…
PrettyPrint is a small, zero-dependency PHP utility that formats arrays in a clean, readable, PyTorch-inspired style. It supports aligned 2D tables, 3D tensors, summarized tensor views, and flexibl...
PHP Array Shapes - potential RFC, looking for feedback
I used AI to draft an implementation of PHP array shapes. I used Claude to implement the idea in PHP's C source - I want to get it out there, full transparency.
Reason I'm posting here: I'd like to see if this is something people would even want in PHP or not. These are extension to PHP's type system enabling devs to use native PHP to relay what's inside an array.
Repository goes into details, so I'll just post the repo here: https://github.com/signalforger/php-array-shapes
There's a patch that enables compiling PHP with the support for array shapes for return types and function parameter types, for version 8.5.1
Looking for honest feedback, does this potential feature appear useful or not? I know this community doesn't pull any punches, let me know what you think :)
https://redd.it/1q1x840
@r_php
I used AI to draft an implementation of PHP array shapes. I used Claude to implement the idea in PHP's C source - I want to get it out there, full transparency.
Reason I'm posting here: I'd like to see if this is something people would even want in PHP or not. These are extension to PHP's type system enabling devs to use native PHP to relay what's inside an array.
Repository goes into details, so I'll just post the repo here: https://github.com/signalforger/php-array-shapes
There's a patch that enables compiling PHP with the support for array shapes for return types and function parameter types, for version 8.5.1
Looking for honest feedback, does this potential feature appear useful or not? I know this community doesn't pull any punches, let me know what you think :)
https://redd.it/1q1x840
@r_php
GitHub
GitHub - signalforger/php-array-shapes: PHP RFC: Array Shape Return Types (draft + implementation)
PHP RFC: Array Shape Return Types (draft + implementation) - signalforger/php-array-shapes
Detecting unauthorized tampering or modifications in Symfony.
Happy New Year!
Starting the first day of the year by shipping a new feature Verify Audit Log Integrity Ensure the integrity of your audit logs by detecting any unauthorized tampering or modifications. This command validates cryptographic hashes to identify compromised records and ensure trustworthiness of audit data.
https://preview.redd.it/0gn2z5inqrag1.png?width=794&format=png&auto=webp&s=92ed22bd55115c61ce92d7184952a4772c510ecd
You can find the code here: AuditTrailBundle
https://redd.it/1q18yoq
@r_php
Happy New Year!
Starting the first day of the year by shipping a new feature Verify Audit Log Integrity Ensure the integrity of your audit logs by detecting any unauthorized tampering or modifications. This command validates cryptographic hashes to identify compromised records and ensure trustworthiness of audit data.
https://preview.redd.it/0gn2z5inqrag1.png?width=794&format=png&auto=webp&s=92ed22bd55115c61ce92d7184952a4772c510ecd
You can find the code here: AuditTrailBundle
https://redd.it/1q18yoq
@r_php
Lychee 7 is released! FrankenPHP, Webshop & background processing
https://lycheeorg.dev/2025-12-31-version-7/
https://redd.it/1q1281q
@r_php
https://lycheeorg.dev/2025-12-31-version-7/
https://redd.it/1q1281q
@r_php
Lychee
Version 7 released!
Another year, another major release for Lychee! Version 7 is here with exciting new features and improvements.
Anyone try PHP dev yet on DHH’s new Omarchy Linux?
How is it? It’s supposed to be geared specifically toward web developers.
https://redd.it/1q3g7m6
@r_php
How is it? It’s supposed to be geared specifically toward web developers.
https://redd.it/1q3g7m6
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
A Week of Symfony #992 (December 29, 2025 – January 4, 2026)
https://symfony.com/blog/a-week-of-symfony-992-december-29-2025-january-4-2026?utm_medium=feed&utm_source=Symfony%20Blog%20Feed
https://redd.it/1q3n39n
@r_php
https://symfony.com/blog/a-week-of-symfony-992-december-29-2025-january-4-2026?utm_medium=feed&utm_source=Symfony%20Blog%20Feed
https://redd.it/1q3n39n
@r_php
Symfony
A Week of Symfony #992 (December 29, 2025 – January 4, 2026) (Symfony Blog)
This week, Symfony 6.4.31, 7.3.9, 7.4.3, and 8.0.3 maintenance versions were released. In addition, we published the 2025 year recap blog post to review the main Symfony activity during the last year.
Built with Laravel. Still early. Feedback welcome.
https://hillel.dev/2026/01/02/why-event-schedule/
https://redd.it/1q3qtyg
@r_php
https://hillel.dev/2026/01/02/why-event-schedule/
https://redd.it/1q3qtyg
@r_php
Hillel Coren
Why Event Schedule?
After working on Invoice Ninja with my amazing partners Shalom and David for over a decade, I started thinking about what comes next. As developers often do, I ended up working on software to try t…
improved HTTP and queue transport handling
# [Audit Transports Documentation](https://github.com/rcsofttech85/AuditTrailBundle)
AuditTrailBundle supports multiple transports to dispatch audit logs. This allows you to offload audit processing to external services or queues, keeping your main application fast.
# 1. Queue Transport (Symfony Messenger)
The Queue transport dispatches audit logs as messages via Symfony Messenger. This is the recommended way to handle audits in high-traffic applications.
# Configuration for Queue transport
Enable the queue transport in `config/packages/audit_trail.yaml`:
audit_trail:
transports:
queue:
enabled: true
bus: 'messenger.bus.default' # Optional: specify a custom bus
You must define a transport named `audit_trail` in `config/packages/messenger.yaml`:
framework:
messenger:
transports:
audit_trail: '%env(MESSENGER_TRANSPORT_DSN)%'
# Advanced Usage: Messenger Stamps
You can pass Messenger stamps (like `DelayStamp` or `DispatchAfterCurrentBusStamp`) in two ways:
# 1. Manually (Programmatic Audits)
Pass them via the `$context` array when creating an audit log or performing a revert.
use Symfony\Component\Messenger\Stamp\DelayStamp;
// Programmatic audit log with a 5-second delay
$auditService->createAuditLog($entity, 'custom_action', null, null, [
'messenger_stamps' => [new DelayStamp(5000)]
]);
# 2. Automatically (Event Subscriber)
Use the `AuditMessageStampEvent` to add stamps to the message right before it is dispatched to the bus. This is the recommended way to add transport-specific stamps.
namespace App\EventSubscriber;
use Rcsofttech\AuditTrailBundle\Event\AuditMessageStampEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;
class AuditMessengerSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
AuditMessageStampEvent::class => 'onAuditMessageStamp',
];
}
public function onAuditMessageStamp(AuditMessageStampEvent $event): void
{
// Add a 5-second delay to all audit logs sent via Queue
$event->addStamp(new DelayStamp(5000));
}
}
# Queue Payload Signing
When `audit_trail.integrity.enabled` is true, the bundle automatically signs the payload to ensure authenticity. The signature is added as a `SignatureStamp` to the Messenger envelope.
use Rcsofttech\AuditTrailBundle\Message\Stamp\SignatureStamp;
// In your message handler
$signature = $envelope->last(SignatureStamp::class)?->signature;
# 2. HTTP Transport
The HTTP transport audit logs to an external API endpoint (e.g., a logging service.
# Configuration for http transport
audit_trail:
transports:
http:
enabled: true
endpoint: 'https://audit-api.example.com/v1/logs'
headers:
'Authorization': 'Bearer your-api-token'
'X-App-Name': 'MySymfonyApp'
timeout: 10 # seconds
# HTTP Payload Signing
When `audit_trail.integrity.enabled` is true, the bundle adds an `X-Signature` header to the HTTP request. This header contains the HMAC signature of the JSON body.
POST /api/logs HTTP/1.1
X-Signature: a1b2c3d4...
Content-Type: application/json
{ ... }
# Payload Structure
The transport sends a `POST` request with a JSON body:
{
"entity_class": "App\\Entity\\Product",
"entity_id": "123",
"action": "update",
"old_values": {"price": 100},
"new_values": {"price": 120},
"changed_fields": ["price"],
"user_id": 1,
"username": "admin",
"ip_address": "127.0.0.1",
"user_agent": "Mozilla/5.0...",
"transaction_hash": "a1b2c3d4...",
"signature":
# [Audit Transports Documentation](https://github.com/rcsofttech85/AuditTrailBundle)
AuditTrailBundle supports multiple transports to dispatch audit logs. This allows you to offload audit processing to external services or queues, keeping your main application fast.
# 1. Queue Transport (Symfony Messenger)
The Queue transport dispatches audit logs as messages via Symfony Messenger. This is the recommended way to handle audits in high-traffic applications.
# Configuration for Queue transport
Enable the queue transport in `config/packages/audit_trail.yaml`:
audit_trail:
transports:
queue:
enabled: true
bus: 'messenger.bus.default' # Optional: specify a custom bus
You must define a transport named `audit_trail` in `config/packages/messenger.yaml`:
framework:
messenger:
transports:
audit_trail: '%env(MESSENGER_TRANSPORT_DSN)%'
# Advanced Usage: Messenger Stamps
You can pass Messenger stamps (like `DelayStamp` or `DispatchAfterCurrentBusStamp`) in two ways:
# 1. Manually (Programmatic Audits)
Pass them via the `$context` array when creating an audit log or performing a revert.
use Symfony\Component\Messenger\Stamp\DelayStamp;
// Programmatic audit log with a 5-second delay
$auditService->createAuditLog($entity, 'custom_action', null, null, [
'messenger_stamps' => [new DelayStamp(5000)]
]);
# 2. Automatically (Event Subscriber)
Use the `AuditMessageStampEvent` to add stamps to the message right before it is dispatched to the bus. This is the recommended way to add transport-specific stamps.
namespace App\EventSubscriber;
use Rcsofttech\AuditTrailBundle\Event\AuditMessageStampEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;
class AuditMessengerSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
AuditMessageStampEvent::class => 'onAuditMessageStamp',
];
}
public function onAuditMessageStamp(AuditMessageStampEvent $event): void
{
// Add a 5-second delay to all audit logs sent via Queue
$event->addStamp(new DelayStamp(5000));
}
}
# Queue Payload Signing
When `audit_trail.integrity.enabled` is true, the bundle automatically signs the payload to ensure authenticity. The signature is added as a `SignatureStamp` to the Messenger envelope.
use Rcsofttech\AuditTrailBundle\Message\Stamp\SignatureStamp;
// In your message handler
$signature = $envelope->last(SignatureStamp::class)?->signature;
# 2. HTTP Transport
The HTTP transport audit logs to an external API endpoint (e.g., a logging service.
# Configuration for http transport
audit_trail:
transports:
http:
enabled: true
endpoint: 'https://audit-api.example.com/v1/logs'
headers:
'Authorization': 'Bearer your-api-token'
'X-App-Name': 'MySymfonyApp'
timeout: 10 # seconds
# HTTP Payload Signing
When `audit_trail.integrity.enabled` is true, the bundle adds an `X-Signature` header to the HTTP request. This header contains the HMAC signature of the JSON body.
POST /api/logs HTTP/1.1
X-Signature: a1b2c3d4...
Content-Type: application/json
{ ... }
# Payload Structure
The transport sends a `POST` request with a JSON body:
{
"entity_class": "App\\Entity\\Product",
"entity_id": "123",
"action": "update",
"old_values": {"price": 100},
"new_values": {"price": 120},
"changed_fields": ["price"],
"user_id": 1,
"username": "admin",
"ip_address": "127.0.0.1",
"user_agent": "Mozilla/5.0...",
"transaction_hash": "a1b2c3d4...",
"signature":
GitHub
GitHub - rcsofttech85/AuditTrailBundle: A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine…
A lightweight, high-performance Symfony bundle that automatically tracks and stores Doctrine ORM entity changes for audit logging and compliance. - rcsofttech85/AuditTrailBundle
"hmac-signature...",
"context": {
"app_version": "1.0.0",
"custom_meta": "value"
},
"created_at": "2024-01-01T12:00:00+00:00"
}
# 3. Doctrine Transport (Default)
The Doctrine transport stores logs in your local database. It is enabled by default.
audit_trail:
transports:
doctrine: true
# 4. Chain Transport (Multiple Transports)
You can enable multiple transports simultaneously. The bundle will automatically use a `ChainAuditTransport` to dispatch logs to all enabled transports.
audit_trail:
transports:
doctrine: true
queue:
enabled: true
# 5. Signature vs. Payload Signing
It is important to distinguish between the two types of signatures:
1. **Entity Signature (**`signature` **field in JSON):**
* Generated at the moment of creation.
* Signs the business data (Entity Class, ID, Changes).
* **Purpose:** Long-term data integrity and non-repudiation. Stored in the database.
2. **Transport Signature (**`X-Signature` **header or** `SignatureStamp`**):**
* Generated just before sending.
* Signs the *entire* payload (including the Entity Signature).
* **Purpose:** Transport security. Ensures the message wasn't tampered with during transit.
https://redd.it/1q3rey3
@r_php
"context": {
"app_version": "1.0.0",
"custom_meta": "value"
},
"created_at": "2024-01-01T12:00:00+00:00"
}
# 3. Doctrine Transport (Default)
The Doctrine transport stores logs in your local database. It is enabled by default.
audit_trail:
transports:
doctrine: true
# 4. Chain Transport (Multiple Transports)
You can enable multiple transports simultaneously. The bundle will automatically use a `ChainAuditTransport` to dispatch logs to all enabled transports.
audit_trail:
transports:
doctrine: true
queue:
enabled: true
# 5. Signature vs. Payload Signing
It is important to distinguish between the two types of signatures:
1. **Entity Signature (**`signature` **field in JSON):**
* Generated at the moment of creation.
* Signs the business data (Entity Class, ID, Changes).
* **Purpose:** Long-term data integrity and non-repudiation. Stored in the database.
2. **Transport Signature (**`X-Signature` **header or** `SignatureStamp`**):**
* Generated just before sending.
* Signs the *entire* payload (including the Entity Signature).
* **Purpose:** Transport security. Ensures the message wasn't tampered with during transit.
https://redd.it/1q3rey3
@r_php
Reddit
From the symfony community on Reddit: improved HTTP and queue transport handling
Explore this post and more from the symfony community
I built a Laravel app for vibe coding Laravel apps from my phone, using my voice
https://x.com/simonhamp/status/2007773433724117138?s=46
https://redd.it/1q3qc0s
@r_php
https://x.com/simonhamp/status/2007773433724117138?s=46
https://redd.it/1q3qc0s
@r_php
X (formerly Twitter)
Simon Hamp (@simonhamp) on X
i'm going to build all my Laravel apps this way from now on
📱 from my phone
🗣️ with my voice
⏰ previewing in realtime
📱 from my phone
🗣️ with my voice
⏰ previewing in realtime