Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:39:19+00:00 2026-06-12T08:39:19+00:00

Possible Duplicate: Using Imagick in Symfony2? I’m new to Symfony so this might be

  • 0

Possible Duplicate:
Using Imagick in Symfony2?

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.

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:

  <?php
  $m = new Mongo();
  $db = $m->myDB;
  $db->find();
  //Do Other DB Operations.

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.

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, it can only persist PHP objects. 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).

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:

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. 

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 the only way to access database in Symfony2? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:39:20+00:00Added an answer on June 12, 2026 at 8:39 am

    Symfony2 works with namespace php. This makes working with non-namespace libraries/classes a bit tricky, but you really just need to know the tricks.

    When you try to use new Mongo() to grab a mongodb object, PHP looks in your current namespace, which means it looks for a mongo() function within your class. To make this work, you need to specify the namespace for mongo. Since it does not use namespaces, PHP places it in the global namespace . So, to correctly reference the function, you need to use new \Mongo(), and PHP will look in your \ namespace instead of your current one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Using same MySQL Connection in different PHP pages This is completely new
Possible Duplicate: Using delegate() with hover()? I am trying this code, but apparently I
Possible Duplicate: Using ASP.NET Controls without databinding My previous question yielded few results so
Possible Duplicate: Using var outside of a method I've searched for this a bit,
Possible Duplicate: Scanner issue when using nextLine after nextInt I am creating a client
Possible Duplicate: C++ using this pointer in constructors Like the title, may I do
Possible Duplicate: Using 'return' in a Ruby block I'm new to Ruby, and was
Possible Duplicate: Using Ember.js, how do I run some js after a view is
Possible Duplicate: Using Git with an existing Xcode project Setting up a git repository
Possible Duplicate: using bash: write bit representation of integer to file I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.