Download the PHP package trebel/schematic without Composer
On this page you can find all versions of the php package trebel/schematic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trebel/schematic
More information about trebel/schematic
Files in trebel/schematic
Package schematic
Short Description Schematic: Schema exchange protocol
License MIT
Homepage https://github.com/manvel-khnkoyan/schematic
Informations about the package schematic
Schematic Protocol
The purpose of this library is to create a schema transfer protocol with the ability to export and import XML.
How does it work
The library helps us create new data types with strict validation and a defined structure.
Data types:
In current version, there are 4 data types: Field, List, Operator, Schema. Every created object is immutable, once created, you cannot change it.
Data type: Trebel\Schematic\Field
Fields are the smallest points of data types, the value of any "Field" must be primitive or we can see below can be Operator:
Data type: Trebel\Schematic\Schema
Schema data type is object-like type, each schema can contain Field, List, or other Schema data types.
Then we can create our first Schema object:
IDis required field for each Schema data type
Data type: Trebel\Schematic\Collection (List)
Collection Why not List? beacouse of list is reserved word in PHP
Lists are data types similar to arrays, and the only difference between a Schema and a List is that List can only handle one type, while Schema can handle any.
Data type: Trebel\Schematic\Operator
Operators are special types, not to define an element, but to modify it.
For example, suppose we have a schema Car with fields ID and Price, and in the case where we want to change the price to add or subtract existing price, we can create Increase operator inside Price
In this version, the operators only work on the Field and List data types. There are defined operators
Push (Trebel\Schematic\Operators\Push),
Pull (Trebel\Schematic\Operators\Pull)
for List data type
Increase (Trebel\Schematic\Operators\Increase)
for Field data type
But you can create your own data types as well.
To support any operator on a Field or List, you need to define all the operators within the types.
Export / Import
The main part of the library is the ability to export and import XML schemas using a specific protocol.
Export Schema
You can only import a schema, not a field, list, or operator.
Let's look at a specific example:
Outpout xml files could be:
File: /tmp/example/index.xml
File: /tmp/example/Car/33.xml
and the same for Car/31.xml
Another example:
output:
Import Schema
Concrete example:
Conclusion
For more information, check out the tutorials located in the folder