Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use the 'raw' PHP Mongodb PECL driver within Symfony2
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7109649/using-imagick-in-symfony2">Using Imagick in Symfony2?</a> </p> </blockquote> <p>I'm new to Symfony so this might be a dummy question. But since after several hours of google I haven't found any related answer it might worth a try here. </p> <p>So basically I was using Windows, Apache, pure PHP, Mongodb and the 'raw' PHP_Mongodb PECL driver (the word 'raw' is used here to differ from the Doctrine Mongodb ODM bundle in Symfony2) for web application development. The PECL driver worked perfectly fine, and I could just write something like this: </p> <pre><code> &lt;?php $m = new Mongo(); $db = $m-&gt;myDB; $db-&gt;find(); //Do Other DB Operations. </code></pre> <p>The above code worked fine without any 'use', 'include' or 'require' statements since I followed the standard instructions and setup the PECL driver extension in php.ini. When showing phpinfo() in the web browser, the Mongodb driver information shows up correctly. Everything's perfect. </p> <p>Then I start to use Symfony2 because it provides url rewriting, MVC pattern, security and other useful stuff. The Doctrine Mongodb ODM bundle works nice except that, seems to me, <strong>it can only persist PHP objects</strong>. I do have a bunch of javascript object in my project to persist and there is simply no way of doing that except to put a 'PHP wrapper' on top of it (to create a PHP object which contains only that javascript object). </p> <p>When I was trying to use the good old PECL trick to talk to the database with the same block of code above, I got this error:</p> <pre><code>Fatal error: Class 'MyProject\Controller\Mongo' not found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Symfony\src\MyProject\Controller\DefaultController.php on line 47. </code></pre> <p>Seems Symfony2 blocked or overwrited the extension paths in php.ini while only looking for its auto class loader. I guess I'll need to change the autoload.php and/or AppKernel.php to include that extension? Please help me understand what's going on here. Can I use the PECL driver in Symfony2 at all? Or is Doctrine Mongodb ODM <strong>the only way</strong> to access database in Symfony2? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload