Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spartaksun/orientdb-entity
Symfony2 OrientDb entity manager
https://github.com/spartaksun/orientdb-entity
Last synced: 1 day ago
JSON representation
Symfony2 OrientDb entity manager
- Host: GitHub
- URL: https://github.com/spartaksun/orientdb-entity
- Owner: spartaksun
- License: apache-2.0
- Created: 2015-08-16T21:21:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-18T09:05:19.000Z (over 9 years ago)
- Last Synced: 2024-05-03T14:14:44.909Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 141 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
OrientDb entity manager
=============================Install
```code
composer require spartaksun/orientdb-entity
```
Example of services.yml:
```yml
services:
orient:
class: PhpOrient\PhpOrient
public: false
properties:
hostname: 'localhost'
port: 2424
username: 'root'
password: 'root'
orient.em:
class: spartaksun\OrientDb\EntityManager
arguments: [@orient, "your_orient_db_name"]
properties:
classMap:
"Country": YourBundle\Entity\Country
```Define entities by extending spartaksun\OrientDb\Entity class.
Use internal validators or define your own by extending abstract spartaksun\OrientDb\Validators\Validator:
```php
/**
* Country entity
* @property $first_name
* @property $last_name
*/
class Country extends spartaksun\OrientDb\Entity
{
/**
* {@inheritdoc}
*/
public function validators()
{
return [
'name' => [
[
spartaksun\OrientDb\Validators\StringValidator::class,
['min' => 3, 'max' => 32],
],
],
];
}
}
```Usage in Symfony2 controller:
```php
$this->get('orient.em');
``````php
// Init repository
$repository = $this->get('orient.em')
->getRepository( Country::class );
```
```php
// Get all countries
$countries = $repository->findAll();
foreach($countries as $country) {
echo $country->name . "\n";
}
```
```php
// Add new country
$country = new Country();
$country->name = 'Ukraine';
```
```php
if($repository->persist($country)) {
$rid = $country->getRid();
} else {
var_dump($country->getErrors());
}
```
```php
// find one
$country = $repository->find('name=?', 'Ukraine')
```