Download the PHP package prewk/seriplating without Composer
On this page you can find all versions of the php package prewk/seriplating. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package seriplating
(De)serialization templater
If you don't know what this does, you probably don't need it and shouldn't use it. :)
Note: This library will have composer install Laravel, which is pretty insane if you don't use Laravel. It uses array and pluralization helper classes from there. I only use it in Laravel currently, so it made sense for me, even though it might not make sense for you. Sorry.
First, an insane amount of preparations
``
Then, time to serialize
``
$serialization
now contains a self-referential array format that can be converted to XML/whatever.
To deserialize it again:
``
Available templating rules
->value()
A valueoptional()->value()
An optional value->id($name)
Primary key,$name
corresponds to the entity name (recommended: db table name)->references($name)
The field refers to a primary id in another entity with the name$name
->optional()->references($name)
An optional reference field->references($name, $fallback)
If references entity is unresolvable, fallback to the given value (typically 0)->conditions($field, [... conditions ...], $default)
Conditionally pick a rule depending on the value of the given field, with an optional fallback$default
rule if no other cases matched.->deep([ ... regexp-indexed rules ....])
A regexp-to-rule array which will run against the given field and apply the rule on matches, the rest of the field is included as-is (Like a->value()
) with array dot notation->hasMany($name)
This field is an array of child entities with their own templating rules registered in theHierarchicalTemplate
->inherits($field)
Value is inherited from the field$field
above in the templating hierarchy->inherits($field1, $field2, ...)
Fallbacks, useful if all entites in a hierarchy needs to inherit someid
from the top, but calls itfoo_id
after the first inherit and downwards->increments()
In a hierarchical deserialization, the parent deserializer will start on0
and count upwards on every entity->increments($start, $increment)
Start value (default0
), and increment value (for instance-1
to decrement instead)
Conditions
``
Deep
``
Increments
``
Formatters
``
Known issues
- Self-referential nesting is buggy and should be avoided, instead of arranging entities of the same type as a tree of themselves, keep them in a flat array with proper references
- Conditional inherits, increments, and hasMany may be buggy
- The code is totally spaghetti atm