|
17 | 17 |
|
18 | 18 | # Syndesi's Cypher Entity Manager |
19 | 19 |
|
20 | | -This library provides an entity manager for Cypher data types. |
21 | | - |
22 | | -Links: |
| 20 | +This library provides an entity manager for Cypher data types. |
| 21 | +This basically means, that you do not have to write create/merge/delete statements for your nodes, relations etc. per |
| 22 | +hand. Instead, you just call `$em->create($node)`, `$em->merge($node)`, `$em->delete($node)` and at the end |
| 23 | +`$em->flush()`. |
23 | 24 |
|
24 | 25 | - [Documentation](https://neo4j-php.github.io/cypher-entity-manager) |
25 | 26 | - [Packagist](https://packagist.org/packages/syndesi/cypher-entity-manager) |
26 | | -- [Neo4j PHP Community](https://github.com/neo4j-php) |
| 27 | + |
| 28 | +## Installation |
| 29 | + |
| 30 | +To install this library, run the following code: |
| 31 | + |
| 32 | +```bash |
| 33 | +composer require syndesi/cypher-entity-manager |
| 34 | +``` |
| 35 | + |
| 36 | +This is all, now you can use the library :D |
| 37 | + |
| 38 | +## Using the library |
| 39 | + |
| 40 | +```php |
| 41 | +use Syndesi\CypherDataStructures\Type\Node; |
| 42 | +use Syndesi\CypherEntityManager\Type\EntityManager; |
| 43 | + |
| 44 | +/** |
| 45 | + * note: the container should be provided by your framework. manual configuration is possible, see documentation |
| 46 | + * @var EntityManagerInterface $em |
| 47 | + */ |
| 48 | +$em = $container->get(EntityManager::class); |
| 49 | + |
| 50 | +$node = new Node(); |
| 51 | +$node |
| 52 | + ->addLabel('NodeLabel') |
| 53 | + ->addIdentifier('id', 123) |
| 54 | + ->addProperty('someProperty', 'someValue') |
| 55 | + ->addIdentifier('id'); |
| 56 | + |
| 57 | +// create a node: |
| 58 | +$em->create($node); |
| 59 | +$em->flush(); |
| 60 | + |
| 61 | +// update a node: |
| 62 | +$node->addProperty('newProperty', 'Hello world :D'); |
| 63 | +$em->merge($node); |
| 64 | +$em->flush(); |
| 65 | + |
| 66 | +// delete a node: |
| 67 | +$em->delete($node); |
| 68 | +$em->flush(); |
| 69 | +``` |
0 commit comments