Download the PHP package tmonier/sylius-audit-log-plugin without Composer

On this page you can find all versions of the php package tmonier/sylius-audit-log-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-audit-log-plugin

Sylius Audit Log Plugin

Français : README.fr.md

Build

Who changed what, when: an audit log of the changes made in the Sylius 2 back office.

A price dropped, a promotion started a day early, a product disappeared from a channel: the Sylius 2 admin cannot tell who did it. The audit plugins written for Sylius 1 were never ported.

This plugin records the creations, updates and deletions of the main Sylius resources with a field-level diff (old → new), the administrator who made them and the request they came from, and shows them in the admin. It is free and open source.

Features

Need What the plugin does
Know who changed a resource, and how Every create / update / delete of the audited resources is recorded with a field-level diff (old → new), the date (UTC), the actor (administrator id + username snapshot, customer, command line or system), the source (admin panel, admin API, shop, shop API, command line) and the route or console command.
Search the trail Configuration › Audit log page: a Sylius grid filtered by date range, resource (type and id), action, actor and actor type, request. Each entry has a page with a readable diff table.
See the history where you work History card on the product (show and edit), order, customer and promotion pages: the last changes of the resource and of what it owns (variants, prices, coupons, payments, addresses...), with a link to the filtered grid.
Group the changes of one save Every entry carries a request id (X-Request-Id header when present): "All changes of this request" lists everything one click changed.
Keep secrets out of the log Passwords, salts, tokens, payment details and gateway configuration are masked: the log says that they changed, never their values. Long texts are truncated.
Respect the GDPR Retention: tmonier:audit-log:purge deletes entries older than retention_days (365 by default). Erasure: tmonier:audit-log:anonymize-customer removes a customer's personal data from the trail. IP addresses are not stored by default (anonymised when enabled).
Audit your own entities Add any Doctrine entity to the configuration; tag your own label or owner resolvers; listen to an event to enrich or skip entries.

Also included: translations in English, French, German, Spanish, Italian, Dutch and Polish; Twig Hooks everywhere; MySQL, MariaDB and PostgreSQL support.

Audit log or timeline?

This plugin is a technical audit trail of the data changed in the back office, for every resource. The sibling plugin tmonier/sylius-timeline-plugin is a business view of an order's life (placed, paid, shipped, e-mails sent) with internal staff notes. They complement each other and can be installed together.

Screenshots

Requirements

Version
PHP 8.2+
Sylius 2.2, 2.3
Symfony 6.4, 7.4, 8.0

Installation

  1. Require the package:

  2. Register the bundle in config/bundles.php (Symfony Flex does it automatically once a recipe exists):

  3. Import the configuration in config/packages/tmonier_sylius_audit_log.yaml:

  4. Import the admin routes in config/routes/tmonier_sylius_audit_log.yaml:

  5. Run the migrations:

  6. Schedule the purge (cron, Symfony Scheduler...), for instance daily:

Configuration

Every key is optional; the defaults are shown.

Audited by default

Resource Owner (history card)
Products (with their translations) —
Variants (incl. stock onHand / onHold), channel prices product
Taxons —
Promotions; their coupons, rules and actions promotion
Catalog promotions; their scopes and actions catalog promotion
Shipping methods, payment methods, tax rates, channels —
Administrators, customers —
Addresses customer (address book) or order (order addresses)
Orders; their payments and shipments order

Translation changes are recorded on the translated resource (name (fr_FR)), many-to-many changes as added / removed lists, references to other resources as a label and an id.

Only the admin, admin_api and cli sources are recorded by default: the shop changes carts, stock and customers all the time, and those changes are not administration. Add shop to sources to record them too. Fixtures loading is not recorded.

Commands

The anonymisation covers the entries of the customer, its addresses, its orders (with their payments, shipments and addresses) and the changes it made from the shop. Entries about a personal resource lose every value and their label; the other entries (orders...) lose the values of the personal fields. The IP address is removed. The administrators who made the changes and the dates stay: the trail remains usable.

Customisation

Labels. Implement Tmonier\SyliusAuditLogPlugin\Resolver\LabelResolverInterface; with autoconfiguration it is tagged tmonier_audit_log.label_resolver (set a priority above 0 to override the core labels).

Owners. Implement Tmonier\SyliusAuditLogPlugin\Resolver\OwnerResolverInterface (tag tmonier_audit_log.owner_resolver) when a property path is not enough to find the parent of an entity.

Entries. Listen to Tmonier\SyliusAuditLogPlugin\Event\AuditLogEntryEvent::PRE_WRITE (tmonier_audit_log.entry.pre_write) to enrich an entry, rewrite its changes or skip it:

Entry class. The entry is a Sylius resource (tmonier_audit_log.audit_log_entry): replace the model under tmonier_sylius_audit_log.models.audit_log_entry.classes.model to add fields; they are written too.

Templates. Every admin block is a Twig hook: tmonier_audit_log.admin.audit_log_entry.* for the entry page, tmonier_audit_log_history in the product, order, customer and promotion hooks for the history cards.

How changes are recorded

A Doctrine listener reads the unit of work in onFlush (old values are still known) and writes the entries in postFlush with plain DBAL inserts (new entities have their ids by then). The inserts run in a savepoint of the caller's transaction when there is one. Writing never flushes the entity manager again, so there is no recursion, and nested flushes keep their own changes. Any error while recording is logged (channel tmonier_audit_log) and swallowed: the audit log never breaks the change it records.

Limitations

Development

B2B demo

This plugin is used in the Sylius B2B demo: a Sylius 2.3 shop with fictitious sample data where the B2B plugins work together. The source code, setup and fixtures of the demo are in that repository.

The demo is an example, not a production setup.

License

MIT. See LICENSE.


All versions of sylius-audit-log-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
sylius/sylius Version ^2.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tmonier/sylius-audit-log-plugin contains the following files

Loading the files please wait ...