entidi / silverstripe-logobject
A DataObjectInterface for storing data using the archive engine of MariaDB/MySQL
Package info
github.com/ntd/silverstripe-logobject
Type:silverstripe-vendormodule
pkg:composer/entidi/silverstripe-logobject
Requires
- silverstripe/framework: ^6.0
Requires (Dev)
- phpstan/extension-installer: ^1.3
- phpunit/phpunit: ^11.3
- silverstripe/standards: ^1
- squizlabs/php_codesniffer: ^3.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-28 18:25:25 UTC
README
Having immutable tables can be useful in many situations, e.g. with logs or GDPR specific requirements. MySQL and MariaDB provide the ARCHIVE engine which seems well suited for this purpose.
Unfortunately, Silverstripe's DataObject class cannot be used directly
with this engine. Silverstripe relies on several $fixed_fields and
database indexes that are tightly coupled to its implementation and
cannot easily be disabled or customized.
This module provides a dedicated DataObjectInterface for log records,
designed to work with the ARCHIVE storage engine. It enforces
restrictions that make sense for append-only logs such as:
- cannot delete or update existing rows
- no
$fixed_fieldsapart fromID - no indexes
- no relations or foreign keys support
- no inheritance complexity: subclasses do not merge fields with the parent classes
License
See License.
This module template defaults to using the "BSD-3-Clause" license. The BSD-3 license is one of the most permissive open-source license and is used by most Silverstripe CMS module.
Installation
composer require entidi/silverstripe-logobject
Documentation
Just use LogObject instead of DataObject, e.g.:
use eNTiDi\LogObject\LogObject; use SilverStripe\ORM\FieldType\DBDatetime; class MyLog extends LogObject { private static $table_name = 'MyLog'; // The `ID` primary key is (always) automatically created private static $db = [ 'Created' => 'Datetime', 'Facility' => "Enum('Auth,Cron,FTP,Mail')", 'Level' => "Enum('Debug,Info,Warning,Error')", 'Message' => 'Varchar(200)', 'PID' => 'Int', ]; } // Save a new row $log = MyLog::create([ 'Created' => DBDatetime::now(), 'Level' => 'Debug', ]); $log->setField('Facility', 'FTP'); $log->Message = 'Some message here...'; $log->PID = 123; $id = $log->write();