Comments (18)
Hi,
I used OrientDB-odm with Symfony2 and I did it this way:
- I created Service called OrientDBService:
namespace ConceptIt\SmartShopperBundle\Services;
use ConceptIt\SmartShopperBundle\Domain;
use Doctrine\OrientDB\Binding\HttpBinding;
use Doctrine\ODM\OrientDB\Mapper;
use Doctrine\ODM\OrientDB as ODM;
use Doctrine\ODM\OrientDB\Manager;
class OrientDBService
{
protected $binding;
protected $mapper;
protected $manager;
public function __construct(Mapper $mapper, HttpBinding $binding, Manager $manager)
{
$this->mapper = $mapper;
$this->binding = $binding;
$this->manager = $manager;
}
public function getBinding()
{
return $this->binding;
}
protected function getMapper()
{
return $this->mapper;
}
public function getManager()
{
return $this->manager;
}
public function getRepository($name)
{
return $this->getManager()->getRepository($name);
}
public function save(\StdClass $object)
{
}
}
- My Resources/config/services.yml file:
services:
orientdb.binding.parameters:
class: Doctrine\OrientDB\Binding\BindingParameters
arguments:
host: %orientdb_host%
port: %orientdb_port%
username: %orientdb_user%
password: %orientdb_password%
database: %orientdb_dbname%
orientdb.binding:
class: Doctrine\OrientDB\Binding\HttpBinding
arguments:
parameters: @orientdb.binding.parameters
odm:
class: Doctrine\ODM\OrientDB\Manager
arguments:
mapper: @odm.mapper
binding: @orientdb.binding
odm.mapper:
class: Doctrine\ODM\OrientDB\Mapper
arguments:
documentProxyDirectory: %orientdb_proxy_dir%
annotationReader: @odm.annotationreader
calls:
- [setDocumentDirectories, [ %orientdb_domain_dir% : %orientdb_domain_namespace% ] ]
odm.annotationreader:
class: Doctrine\ODM\OrientDB\Mapper\Annotations\Reader
arguments:
cacheReader: @cache.array
cache.array:
class: Doctrine\Common\Cache\ArrayCache
conceptit.orientdb:
class: ConceptIt\SmartShopperBundle\Services\OrientDBService
arguments:
mapper: @odm.mapper
binding: @orientdb.binding
manager: @odm
- My parameters.yml
parameters:
orientdb_host: 127.0.0.1
orientdb_port: 2480
orientdb_dbname: smartshopper
orientdb_user: user
orientdb_password: password
orientdb_proxy_dir: %kernel.root_dir%/cache
orientdb_domain_dir: %kernel.root_dir%/../src/ConceptIt/SmartShopperBundle/Entity
orientdb_domain_namespace: ConceptIt\SmartShopperBundle\Entity
- I used my orientddb service:
$manager = $this->container->get('conceptit.orientdb')->getManager();
I hope this helps.
from orientdb-odm.
thanks @tomcyr!
this might help as well!
from orientdb-odm.
Thanks for the help, really appreciate it!
I think I'm almost there the, it already connects to the database but I get this error:
Unable to find a PHP class mapped for "Product".
500 Internal Server Error - OClassNotFoundException
It seems the proxy classes aren't being generated in the documentProxyDirectory.
is there something that I need to add to the app/autoload.php file in Symfony?
@tomcyr I'm adapting from your bundle https://github.com/tomcyr/OrientDbBundle
from orientdb-odm.
@introfini can You show Your Entity class with namespaces ?? And Your code how You use Your Entity ??
from orientdb-odm.
Hi @tomcyr!
This is just test adapted code taken from here http://odino.org/starting-to-play-with-the-doctrine-orientdb-odm/.
First I tried using your Bundle but I got the same error, then I started all again from the above tutorial and got the same error again. For what I can see (I'm really new with Symfony and Doctrine) the proxy classes aren't being generated in the cache directory.
My Entity class: Product.php
<?php
namespace Genehome\OrientDBBundle\Entity;
use Doctrine\ODM\OrientDB\Mapper\Annotations as ODM;
/**
* @ODM\Document(class="product")
*/
class Product
{
/**
* @ODM\Property(name="@rid", type="string")
*/
protected $rid;
/**
* @ODM\Property(type="string")
*/
protected $email;
/**
* @ODM\Property(type="string", notnull="false")
*/
protected $nick;
/**
* @ODM\Property(type="linklist")
*/
protected $addresses;
/**
* Returns the nickname of the user, or his email if he has no nick set.
*
* @return string
*/
public function getNick()
{
return $this->nick ?: $this->getEmail();
}
public function setNick($nick)
{
$this->nick = $nick;
}
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getAddresses()
{
return $this->addresses;
}
public function setAddresses($adresses)
{
$this->addresses = $addresses;
}
public function getRid()
{
return $this->rid;
}
public function setRid($rid)
{
$this->rid = $rid;
}
}
My controller
namespace Genehome\OrientDBBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Genehome\OrientDBBundle\Entity\Product;
use Doctrine\ODM\OrientDB\Manager;
class DefaultController extends Controller
{
public function indexAction($name)
{
$product = new Product();
$manager = $this->get('odm');
$repository = $manager->getRepository('Genehome\OrientDBBundle\Entity\Product');
$product = $repository->findAll();
return new Response($product);
}
}
My services.yml
services:
orientdb.binding.parameters:
class: Doctrine\OrientDB\Binding\BindingParameters
arguments:
host: 127.0.0.1
port: 2480
username: admin
password: admin
database: GratefulDeadConcerts
orientdb.binding:
class: Doctrine\OrientDB\Binding\HttpBinding
arguments:
parameters: @orientdb.binding.parameters
odm:
class: Doctrine\ODM\OrientDB\Manager
arguments:
mapper: @odm.mapper
binding: @orientdb.binding
odm.mapper:
class: Doctrine\ODM\OrientDB\Mapper
arguments:
documentProxyDirectory: %kernel.root_dir%/cache
annotationReader: @odm.annotationreader
calls:
- [setDocumentDirectories, [ %kernel.root_dir%/../src/Genehome/OrientDBBundle/Entity/ : "Genehome\OrientDBBundle\Entity" ] ]
odm.annotationreader:
class: Doctrine\ODM\OrientDB\Mapper\Annotations\Reader
arguments:
cacheReader: @cache.array
cache.array:
class: Doctrine\Common\Cache\ArrayCache
from orientdb-odm.
Maybe the problem is in service.yml
change:
- [setDocumentDirectories, [ %kernel.root_dir%/../src/Genehome/OrientDBBundle/Entity/ : "Genehome\OrientDBBundle\Entity" ] ]
into:
- [setDocumentDirectories, [ %kernel.root_dir%/../src/Genehome/OrientDBBundle/Entity : "Genehome\OrientDBBundle\Entity" ] ]
from orientdb-odm.
No, no luck :-(
Thanks @tomcyr
from orientdb-odm.
Hmm... Maybe if You try run Your app in app_dev.php the error will be more readable ??
Please try url: http://yourHost/app_dev.php instead of app.php and paste an error.
from orientdb-odm.
the error means that there is no class mapped to hydrate that specific entity, which means it cant find the entity classes, as @tomcyr pointed out. I found another configuration Im using on a Sf2 projects and it looks like:
odm.mapper:
class: Doctrine\ODM\OrientDB\Mapper
arguments:
documentProxyDirectory: %kernel.root_dir%/cache/
annotationReader: @odm.annotation_reader
calls:
- [setDocumentDirectories, [ %kernel.root_dir%/../src/Vendor/Entity/ : "Vendor\Entity" ] ]
which is kinda the same that you're using but works here :) can you try to see where the ODM it's looking for entity classes var dumping here?
from orientdb-odm.
@odino the $class variable doesn't get any value there. I followed the path that creates the variable and got to getClassByPath function where it fails.
The problem that I found is that here the explode '/' on the path doesn't work (because I'm on Windows?). If I change that to $namespaces = explode('\\', $absPath);
things get better because the proxy classes are created (they weren't before) on the cache directory but now I think I'm missing a "use" somewhere:
New error:
Attempted to load class "Product" from namespace "Doctrine\OrientDB\Proxy\Genehome\OrientDBBundle\Entity" in C:\wamp\www\Symfony2\vendor\doctrine\orientdb-odm\src\Doctrine\ODM\OrientDB\Mapper.php line 219. Do you need to "use" it from another namespace?
500 Internal Server Error - ClassNotFoundException
Thanks!
from orientdb-odm.
Hmm... I think that is Windows problem... @introfini can you try:
$repository = $manager->getRepository('\Genehome\OrientDBBundle\Entity\Product');
the Product class is loaded from bad namespace:
"Doctrine\OrientDB\Proxy\Genehome\OrientDBBundle\Entity" not "Genehome\OrientDBBundle\Entity"
from orientdb-odm.
oh wow crazy :) I honestly never checked the build on windows, if you can debug it that would be super-helpful!
from orientdb-odm.
Hi
I was running in exact the same issues working on a windows machine. I cannot fix the bug but at least I can tell where it is located and to get it work again I changed:
Doctrine\ODM\OrientDB\Mapper.php (line 381):
$namespaces = explode('//', $absPath);
to...
$namespaces = explode('\\', $absPath);
Doctrine\ODM\OrientDB\Mapper.php (line 218):
Changed...
$proxyClass = $this->getProxyClass($class);
to...
$proxyClass = $class;
Hope it helps!
from orientdb-odm.
hey @mastacash would you be able to send a PR with the fix? I can totally see why the first line would need to be fixed but Im not sure about the 2nd one, what is the error if you only apply the first fix?
from orientdb-odm.
Hi odino
I did some debugging and it is exactly related to the same issue as reported in #153, the fact that Symfony's Finder class returns mixed directory separators when working in a windows environment. Basically the Proxy files are failing when calling the class_exists(...)
function in the Mapper class.
Unfortunately I have no idea how to fix this except switching to a Linux environment ;)
from orientdb-odm.
ok maybe we can replace the separators with DIRECTORY_SEPARATOR
, can you try?
from orientdb-odm.
What is missing for windows is the path of the proxy classes in the $classMapper
, instead of the path it was always 0.
By adding the following line to the composer.json file I fixed the problem:
"autoload": {
"psr-0": {
"": "src/",
"SymfonyStandard": "app/",
"Doctrine\\OrientDB\\Proxy": "app/cache/"
}
},
Don't forget to run composer install after changing.
In addtion, I figured out that the requested changes with the DIRECTORY_SEPARATOR
are already available in the #153 branch. I run all the test successful.
from orientdb-odm.
Ok! :)
from orientdb-odm.
Related Issues (20)
- HTTP Client Separation HOT 3
- what happened to the github-wiki HOT 1
- problem with composer "symfony/finder": "2.1.*" HOT 3
- Connection or reconnection strange behavior in response time HOT 18
- Use maven to install OrientDB in travis HOT 3
- Missing 'LIKE' detection on Command 'where' method HOT 5
- Question mark in a query causes a server parsing error HOT 3
- Question
- Use with Laravel 4 HOT 2
- [Proxy] Implement a proper ProxyFactory HOT 2
- [Caster] Cache usage
- SQL Update returns Cannot execute non idempotent command HOT 1
- Use as Symfony service HOT 9
- Fatal error: Class 'Doctrine\ODM\OrientDB\Mapper' not found HOT 8
- Binary protocol? HOT 12
- Tests failing HOT 5
- Fatal error: Call to a member function getId() on a non-object
- Active HOT 3
- State of the project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orientdb-odm.