can not get mongodb to work with php on windows

807 views
Skip to first unread message

gd52

unread,
Jan 4, 2013, 2:45:09 PM1/4/13
to mongod...@googlegroups.com
I am using the 32 bit php builtin server on Windows 7 (64 bit)
I am using the 32 bit version so that I can get xdebug working with the php visual studio plug in.

in php.ini, i have:
extension=php_mongo.dll
in the php ext folder i have:
php_mongo.dll (the 32 bit driver)
I have also tried the various 64 bit thread safe and unthread safe versions of the driver.

But as soon as I do
$m = new Mongo()
I get an exception that the class Mongo can not be found.
Also Mongo does not appear in phpinfo().

Any help please!!!

Derick Rethans

unread,
Jan 4, 2013, 2:50:34 PM1/4/13
to mongod...@googlegroups.com
On Fri, 4 Jan 2013, gd52 wrote:

> I am using the 32 bit php builtin server on Windows 7 (64 bit)
> I am using the 32 bit version so that I can get xdebug working with the php
> visual studio plug in.
>
> in php.ini, i have:
> extension=php_mongo.dll
> in the php ext folder i have:
> php_mongo.dll (the 32 bit driver)

Which exact original filename did you use? And where did you download
it?

Can you also post the first block of phpinfo() output here?

cheers,
Derick

--
{
website: [ "http://mongodb.org", "http://derickrethans.nl" ],
twitter: [ "@derickr", "@mongodb" ]
}

Gary Dryden

unread,
Jan 4, 2013, 3:03:57 PM1/4/13
to mongod...@googlegroups.com
Thanks for the quick reply.
I just finished the M102 so I am not a real newbie to mongodb.
I have been using it for over a year in .NET and node.js.
Just starting to try to use it with php.

I will attach my php.ini.
Just to throw a wrench in there, you will also see that I am using xdebug (not thread safe) and this works fine as it allows me to single step through php using visual studio

I suspect that I am using the the wrong version of the php dll. Yhere are 4 versions and I think I have tried them all, but maybe not.
I am using a 32 bit version of php, because, that is the only version that xdebug works with (although I am using the 64 bit version of mongodb)

I got the drivers from your php driver site today.




}

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

phpinfo99.htm
php.ini

Gary Dryden

unread,
Jan 4, 2013, 3:09:51 PM1/4/13
to mongod...@googlegroups.com
Here is the code I am running:

<?php

phpinfo();

$user = array(
'first_name' => 'MongoDB',
'last_name' => 'Fan',
'tags' => array('developer','user')
);


// Configuration
$dbhost = 'localhost';
$dbname = 'test';
try
{
    // Connect to test database

    $m = new Mongo("mongodb://$dbhost");
    $db = $m->$dbname;

    // Get the users collection
    $c_users = $db->users;

    // Insert this new document into the users collection
    $c_users->save($user);
}
catch(MongoConnectionException $e)
{
    die('Error: ' . $e->getMessage());
}
    
    
?>

mongodb is running because i can shell to it.



On Fri, Jan 4, 2013 at 2:50 PM, Derick Rethans <der...@10gen.com> wrote:
}

Derick Rethans

unread,
Jan 4, 2013, 3:13:14 PM1/4/13
to mongod...@googlegroups.com
On Fri, 4 Jan 2013, Gary Dryden wrote:

> Thanks for the quick reply.
> I just finished the M102 so I am not a real newbie to mongodb.
> I have been using it for over a year in .NET and node.js.
> Just starting to try to use it with php.
>
> I will attach my php.ini.
> Just to throw a wrench in there, you will also see that I am using xdebug
> (not thread safe) and this works fine as it allows me to single step
> through php using visual studio

Yay! :-)

>
> I suspect that I am using the the wrong version of the php dll. Yhere are 4
> versions and I think I have tried them all, but maybe not.
> I am using a 32 bit version of php, because, that is the only version that
> xdebug works with

That's not really true - Xdebug works fine with 64 bit PHP versions.
However, the PHP development team doesn't really support 64 bit PHP
builds on Windows sadly.

> (although I am using the 64 bit version of mongodb)
>
> I got the drivers from your php driver site today.

You're currently trying to load the 64bit version of the driver though:

extension=php_mongo-1.3.0-5.4-vc9-nts-x86_64.dll

That's wrong, you need the php_mongo-1.3.0-5.4-vc9-nts.dll file, just
like you do with xdebug (both binaries are made with the same settings
on the same machine after all).

Gary Dryden

unread,
Jan 4, 2013, 5:10:54 PM1/4/13
to mongod...@googlegroups.com
Still not working!

Here is my php.ini

BTW: I don't care that I can only use 32 bits on Windows.
That is the development environment so that I can use a visual debugger and single step.
The production environment is linux.




php.ini

Derick Rethans

unread,
Jan 7, 2013, 6:31:05 AM1/7/13
to mongod...@googlegroups.com
On Fri, 4 Jan 2013, Gary Dryden wrote:

> Still not working!
>
> Here is my php.ini

Is the php_mongo-1.3.0-5.4-vc9-nts.dll file in the directory with all
the other extension's dlls?

Gary Dryden

unread,
Jan 7, 2013, 8:25:25 AM1/7/13
to mongod...@googlegroups.com
php.ini excerp:
[xdebug] 
zend_extension = "C:\php-5.4.8\ext\php_xdebug-2.2.1-5.4-vc9-nts.dll"

[xdebug] 
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host="localhost"
xdebug.remote_port=9000

extension="C:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll"


partial dir listing:
C:\php-5.4.8>dir ext\php_mongo*
 Volume in drive C is Acer
 Volume Serial Number is 163A-92C3

 Directory of C:\php-5.4.8\ext

04/01/2013  02:32 PM           256,000 php_mongo-1.3.0-5.4-vc9-nts-x86_64.dll
07/01/2013  08:10 AM           204,288 php_mongo-1.3.0-5.4-vc9-nts.dll
04/01/2013  02:32 PM           287,232 php_mongo-1.3.0-5.4-vc9-x86_64.dll
04/01/2013  01:23 PM           225,792 php_mongo.dll
               4 File(s)        973,312 bytes
               0 Dir(s)  285,178,605,568 bytes free

Why is this so difficult?

thanks

Gary



Gary Dryden

unread,
Jan 7, 2013, 1:00:46 PM1/7/13
to mongod...@googlegroups.com
Derick

any luck on figuring out what my configuration error could be

Gary



On Mon, Jan 7, 2013 at 6:31 AM, Derick Rethans <der...@10gen.com> wrote:

Derick Rethans

unread,
Jan 7, 2013, 2:25:22 PM1/7/13
to mongod...@googlegroups.com
On Mon, 7 Jan 2013, Gary Dryden wrote:

> any luck on figuring out what my configuration error could be

Nope - it works fine for me. Can you try this on the command line
perhaps:

Go to the directory where your php.exe and php5.dll are, for me:

cd D:\PHP\VC9-x86\php-5.4dev\Release>

Run:

php -n -dextension=d:\php\php_mongo-master-5.4-vc9-nts.dll --ri mongo

-n is to disable all other extensions
-dextension with the full path should load the extension
--ri mongo shows the php ini section for the mongo driver

Of course, substitute your paths for the correct ones.

Gary Dryden

unread,
Jan 7, 2013, 2:34:50 PM1/7/13
to mongod...@googlegroups.com
here is the output

C:\php-5.4.8>php -n dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll --ri mongo
Could not open input file: dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll

C:\php-5.4.8>dir ext\php_mongo-1.3.0-5.4-vc9-nts.dll
 Volume in drive C is Acer
 Volume Serial Number is 163A-92C3

 Directory of C:\php-5.4.8\ext

07/01/2013  08:10 AM           204,288 php_mongo-1.3.0-5.4-vc9-nts.dll
               1 File(s)        204,288 bytes

here is a part of my php.ini

[xdebug] 
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host="localhost"
xdebug.remote_port=9000

extension="C:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll"

[PHP_CURL]
extension=php_curl.dll

do i need my extension in an ini section???



Sam Millman

unread,
Jan 7, 2013, 3:49:01 PM1/7/13
to mongod...@googlegroups.com
You missed out the - on the d in your first command, try again.

Sam Millman

unread,
Jan 7, 2013, 3:50:37 PM1/7/13
to mongod...@googlegroups.com
No extensions do not need to be in a ini section, doesn't hurt but it doesn't need to be.

Gary Dryden

unread,
Jan 7, 2013, 3:52:47 PM1/7/13
to mongod...@googlegroups.com
Here's the output:

C:\php-5.4.8>php -n -dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll
 --ri mongo

mongo

MongoDB Support => enabled
Version => 1.3.0

Directive => Local Value => Master Value
mongo.allow_persistent => 1 => 1
mongo.default_host => localhost => localhost
mongo.default_port => 27017 => 27017
mongo.chunk_size => 262144 => 262144
mongo.cmd => $ => $
mongo.utf8 => 1 => 1
mongo.native_long => 0 => 0
mongo.long_as_object => 0 => 0
mongo.allow_empty_keys => 0 => 0
mongo.no_id => 0 => 0
mongo.ping_interval => no value => no value
mongo.is_master_interval => no value => no value

So it looks like it can load.
Why does phpinfo() not see it and why does new Mongo() fail.

Sam Millman

unread,
Jan 7, 2013, 3:56:13 PM1/7/13
to mongod...@googlegroups.com
try new MongoClient()

Derick Rethans

unread,
Jan 7, 2013, 4:29:06 PM1/7/13
to mongod...@googlegroups.com
On Mon, 7 Jan 2013, Gary Dryden wrote:

> here is the output
>
> C:\php-5.4.8>php -n
> dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll --ri mongo

You missed the "-" in front of "dextension".

> extension="C:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll"

Tried removing the double quotes too?

> [PHP_CURL]
> extension=php_curl.dll
>
> do i need my extension in an ini section???

No - those are ignored.

Derick Rethans

unread,
Jan 7, 2013, 4:29:53 PM1/7/13
to mongod...@googlegroups.com
On Mon, 7 Jan 2013, Sam Millman wrote:

> try new MongoClient()

Both MongoClient and Mongo should always exist in 1.3, so that's not
going to help.

Sam Millman

unread,
Jan 7, 2013, 4:30:57 PM1/7/13
to mongod...@googlegroups.com
True I thought I would throw it out there though to see if there was something weird going on


Sam Millman

unread,
Jan 8, 2013, 5:45:16 AM1/8/13
to mongod...@googlegroups.com
I have thought of one thing just now. How are you running PHP?

Are you running it in fast cgi mode with mpm cos the default behaviour of MPM is to actually cache your PHP ini file so you have to restart the mpm-worker for it take the new config.

It is a random thought by me but it could be one that you are seeing.

Gary Dryden

unread,
Jan 8, 2013, 10:39:12 AM1/8/13
to mongod...@googlegroups.com
I am running the built in web server.
Here is what is weird.
When I run:
php -n -dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll --ri mongo
I get good output.
When other people run phpinfo() they see a Mongodb section in the output. I do not.
It looks like the builtin server is not recognizing the mongo driver.
Has anyone else used mongodb with the builtin server?

Derick Rethans

unread,
Jan 8, 2013, 11:05:20 AM1/8/13
to mongod...@googlegroups.com
On Tue, 8 Jan 2013, Gary Dryden wrote:

> I am running the built in web server.
>
> Here is what is weird.
> When I run:
> php -n -dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll --ri mongo
>
> I get good output.
>
> When other people run phpinfo() they see a Mongodb section in the
> output. I do not. It looks like the builtin server is not recognizing
> the mongo driver. Has anyone else used mongodb with the builtin
> server?

Not sure what you mean by "builtin" server - but which php.ini file are
you editting? Are you sure it is C:\php-5.4.8\php.ini ? Also, did you
remove the "'s in php.ini as I asked previously?

Sam Millman

unread,
Jan 8, 2013, 11:07:03 AM1/8/13
to mongod...@googlegroups.com
But I have never used it before so I am unsure of the technical stuff here


Derick Rethans

unread,
Jan 8, 2013, 11:21:00 AM1/8/13
to mongod...@googlegroups.com
On Tue, 8 Jan 2013, Sam Millman wrote:

> He is using: http://php.net/manual/en/features.commandline.webserver.php
>
> But I have never used it before so I am unsure of the technical stuff here

Ah - of course. THere is no reason why that should work differently than
a normal CLI script.

The following does work for me too:

php -n -dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll --ri mongo -S localhost:58812

And then requesting a file with <?php phpinfo(); ?> through
http://localhost:58812/info.php

Only thing I can think of is that something is wrong in the php.ini file
why it doesn't want to load - I *suspect* curly quotes almost...

gd52

unread,
Jan 9, 2013, 9:35:26 AM1/9/13
to mongod...@googlegroups.com
I am not sure what ""s you are talking about. I can't find the post that you are refering to.

Derick Rethans

unread,
Jan 9, 2013, 9:41:12 AM1/9/13
to mongod...@googlegroups.com
On Wed, 9 Jan 2013, gd52 wrote:

> I am not sure what ""s you are talking about. I can't find the post that
> you are refering to.

This one:

On Mon, 7 Jan 2013, Gary Dryden wrote:

> here is the output
>
> C:\php-5.4.8>php -n
> dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll --ri mongo

You missed the "-" in front of "dextension".

> extension="C:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll"

Tried removing the double quotes too?

gd52

unread,
Jan 9, 2013, 10:16:12 AM1/9/13
to mongod...@googlegroups.com
I took out the "s around the name, still crashes.

[xdebug] 
zend_extension = "C:\php-5.4.8\ext\php_xdebug-2.2.1-5.4-vc9-nts.dll"

[xdebug] 
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host="localhost"
xdebug.remote_port=9000

extension=php_mongo-1.3.0-5.4-vc9-nts.dll



phpinfo();

$user = array(
'first_name' => 'MongoDB',
'last_name' => 'Fan',
'tags' => array('developer','user')
);


// Configuration
$dbhost = 'localhost';
$dbname = 'test';
try
{
    // Connect to test database

    $m = new Mongo("mongodb://$dbhost");   <-- crashes here, doesn't even throw an exception that I can catch
    $db = $m->$dbname;

gd52

unread,
Jan 9, 2013, 5:21:30 PM1/9/13
to mongod...@googlegroups.com
Ok
Can we go back to first principles.
Can you connect to mongodb using the builtin server on windows 7 with  32 bit php?

Gary

Derick Rethans

unread,
Jan 10, 2013, 5:57:26 AM1/10/13
to mongod...@googlegroups.com
On Wed, 9 Jan 2013, gd52 wrote:

> Ok
> Can we go back to first principles.
> Can you connect to mongodb using the builtin server on windows 7 with 32
> bit php?

Yes I can. See http://derickrethans.nl/files/dump/cli-server-mongo.jpg

Gary Dryden

unread,
Jan 10, 2013, 9:41:36 AM1/10/13
to mongod...@googlegroups.com
I am not sure what version of php you are running, but then i type
php -h
I do not see a -S or -d options
also my mongo driver is called
php_mongo-1.3.0-5.4-vc9-nts.dll

My php also does not have a release folder

Am I running the same version of php and the mongo driver as you are.

Also when entering the code in visual studio, the code completion does not show that MongoClient exists.



Gary Dryden

unread,
Jan 10, 2013, 10:02:05 AM1/10/13
to mongod...@googlegroups.com
I downloaded red gate's .net reflector and loaded 
php_mongo-1.3.0-5.4-vc9-nts.dll
reflector says that the file is not a .net module


On Thu, Jan 10, 2013 at 5:57 AM, Derick Rethans <der...@10gen.com> wrote:

Derick Rethans

unread,
Jan 10, 2013, 10:06:13 AM1/10/13
to mongod...@googlegroups.com
On Thu, 10 Jan 2013, Gary Dryden wrote:

> I am not sure what version of php you are running, but then i type
> php -h
> I do not see a -S or -d options

What exactly *do* you see then when you run php -h and what with php -v?

And how do you start the "build-in" server? What is the exact command
line that you use?

> also my mongo driver is called
> php_mongo-1.3.0-5.4-vc9-nts.dll

It's the same thing, just a different name - although technically mine
is version 1.3.2 and not 1.3.0.

> My php also does not have a release folder

Again, that doesn't really matter. Mine's just a in a different path
called "Release".

Derick Rethans

unread,
Jan 10, 2013, 10:06:48 AM1/10/13
to mongod...@googlegroups.com
On Thu, 10 Jan 2013, Gary Dryden wrote:

> I downloaded red gate's .net reflector and loaded
> php_mongo-1.3.0-5.4-vc9-nts.dll
> reflector says that the file is not a .net module

RIght, why should it be? It's a DLL, not a .net module.

Gary Dryden

unread,
Jan 10, 2013, 10:15:14 AM1/10/13
to mongod...@googlegroups.com
php -v
PHP 5.4.8 (cli) (built: Oct 16 2012 22:30:02)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

Are you the author of php. I thought you worked for mongo

C:\php-5.4.8>php -h
Usage: php [options] [-f] <file> [--] [args...]
   php [options] -r <code> [--] [args...]
   php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
   php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
   php [options] -- [args...]
   php [options] -a

  -a               Run interactively
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse and execute <file>.
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -r <code>        Run PHP <code> without using script tags <?..?>
  -B <begin_code>  Run PHP <begin_code> before processing input lines
  -R <code>        Run PHP <code> for every input line
  -F <file>        Parse and execute <file> for every input line
  -E <end_code>    Run PHP <end_code> after processing all input lines
  -H               Hide any passed arguments from external tools.
  -S <addr>:<port> Run with built-in web server.
  -t <docroot>     Specify document root <docroot> for built-in web server.
  -s               Output HTML syntax highlighted source.
  -v               Version number
  -w               Output source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.

  args...          Arguments passed to script. Use -- args when first argument
                   starts with - or script is read from stdin

  --ini            Show configuration file names

  --rf <name>      Show information about function <name>.
  --rc <name>      Show information about class <name>.
  --re <name>      Show information about extension <name>.
  --rz <name>      Show information about Zend extension <name>.
  --ri <name>      Show configuration for extension <name>.


Also reflector doesn't think that the mongo driver is a valid .net module.

goto www.reflector.net to download a free trial version and you will see what i mean.



Sam Millman

unread,
Jan 10, 2013, 10:18:07 AM1/10/13
to mongod...@googlegroups.com
As derick said the driver isn't a .net module. It is a dymincally linked library representing a PHP extension.

The -S options exists in your output:


-S <addr>:<port> Run with built-in web server.

run something like php -S you shouldn't need the address and port, PHP should be able to just take the default port and a local IP

Derick Rethans

unread,
Jan 10, 2013, 10:28:31 AM1/10/13
to mongod...@googlegroups.com
On Thu, 10 Jan 2013, Gary Dryden wrote:

> php -v
> PHP 5.4.8 (cli) (built: Oct 16 2012 22:30:02)
> Copyright (c) 1997-2012 The PHP Group
> Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
> with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
>
> Are you the author of php. I thought you worked for mongo

No, I wrote Xdebug and I work for 10gen (MongoDB makers).

>
> C:\php-5.4.8>php -h
> Usage: php [options] [-f] <file> [--] [args...]
> php [options] -r <code> [--] [args...]
> php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
> php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
> php [options] -- [args...]
> php [options] -a
>
> -a Run interactively
> -c <path>|<file> Look for php.ini file in this directory
> -n No php.ini file will be used
> -d foo[=bar] Define INI entry foo with value 'bar'

Here is the -d option.

> -e Generate extended information for debugger/profiler
> -f <file> Parse and execute <file>.
> -h This help
> -i PHP information
> -l Syntax check only (lint)
> -m Show compiled in modules
> -r <code> Run PHP <code> without using script tags <?..?>
> -B <begin_code> Run PHP <begin_code> before processing input lines
> -R <code> Run PHP <code> for every input line
> -F <file> Parse and execute <file> for every input line
> -E <end_code> Run PHP <end_code> after processing all input lines
> -H Hide any passed arguments from external tools.
> -S <addr>:<port> Run with built-in web server.

Here is the -S option.

You didn't quite answer which command line you use to get the built in
server to run though - could you please answer that too?

Derick Rethans

unread,
Jan 10, 2013, 10:29:38 AM1/10/13
to mongod...@googlegroups.com
On Thu, 10 Jan 2013, Sam Millman wrote:

> The -S options exists in your output:
>
> -S <addr>:<port> Run with built-in web server.
>
> run something like php -S you shouldn't need the address and port, PHP
> should be able to just take the default port and a local IP

Sorry, but addr and port are required. You can't set a "default port" as
you need to tell the server on which port to run.

Sam Millman

unread,
Jan 10, 2013, 10:41:03 AM1/10/13
to mongod...@googlegroups.com
Ah yea at a quick glance I mis read the man page as saying that it defaults to localhost:8000 but that was jus the examples: http://php.net/manual/en/features.commandline.webserver.php


Gary Dryden

unread,
Jan 10, 2013, 11:04:59 AM1/10/13
to mongod...@googlegroups.com
ok i am getting closer. when i run:
C:\php-5.4.8>php -S 127.0.0.1:8600 -n -dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll

then access the file:
<?php
phpinfo();
?>

I see a mongodb section in the output.

When I run:
C:\php-5.4.8>php -S 127.0.0.1:8600

with this in the php.ini file:
[xdebug] 
zend_extension = "C:\php-5.4.8\ext\php_xdebug-2.2.1-5.4-vc9-nts.dll"

[xdebug] 
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host="localhost"
xdebug.remote_port=9000

extension=php_mongo-1.3.0-5.4-vc9-nts.dll

Theen phpinfo() does not show a mongodb section in the output.
It is as if the extension is not being recognized.




Derick Rethans

unread,
Jan 10, 2013, 12:00:48 PM1/10/13
to mongod...@googlegroups.com
On Thu, 10 Jan 2013, Gary Dryden wrote:

> ok i am getting closer. when i run:
> C:\php-5.4.8>php -S 127.0.0.1:8600 -n
> -dextension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll
>
> then access the file:
> <?php
> phpinfo();
> ?>
>
> I see a mongodb section in the output.
>
> When I run:
> C:\php-5.4.8>php -S 127.0.0.1:8600
>
> with this in the php.ini file:
> [xdebug]
> zend_extension = "C:\php-5.4.8\ext\php_xdebug-2.2.1-5.4-vc9-nts.dll"
>
> [xdebug]
> xdebug.remote_enable=on
> xdebug.remote_handler=dbgp
> xdebug.remote_host="localhost"
> xdebug.remote_port=9000
>
> extension=php_mongo-1.3.0-5.4-vc9-nts.dll

And what if you change that line to:
extension=c:\php-5.4.8\ext\php_mongo-1.3.0-5.4-vc9-nts.dll

Gary Dryden

unread,
Jan 10, 2013, 12:25:37 PM1/10/13
to mongod...@googlegroups.com
FINALLY!!!!!
I made your last suggested change and I now see mongo info in phpinfo()
So I know it can load.

My problem now is that I get an exception when doing new MongoClient() when running through visual studio, but that is probably a problem with the visual studio plugin.
So I will continue with the problem with the plugin author.
Thanks for your help.

On Thu, Jan 10, 2013 at 12:00 PM, Derick Rethans <der...@10gen.com> wrote:
c:\php-5.4.8\ext\


Gary Dryden

unread,
Jan 10, 2013, 12:41:02 PM1/10/13
to mongod...@googlegroups.com
oops, not done yet.

I get a crash when I run this code.

<?php
phpinfo();



$user = array(
'first_name' => 'MongoDB',
'last_name' => 'Fan',
'tags' => array('developer','user')
);


// Configuration
$dbhost = 'localhost';
$dbname = 'test';
try
{
    // Connect to test database

    $m = new MongoClient("mongodb://$dbhost");
    $db = $m->$dbname;

    // Get the users collection
    $c_users = $db->users;

    // Insert this new document into the users collection
    $c_users->save($user);
}
catch(MongoConnectionException $e)
{
    die('Error: ' . $e->getMessage());
}
echo 'done';


?>
It crashes on the new MongoClient()
It never gets to the catch block.



On Thu, Jan 10, 2013 at 12:00 PM, Derick Rethans <der...@10gen.com> wrote:

Sam Millman

unread,
Jan 10, 2013, 12:49:23 PM1/10/13
to mongod...@googlegroups.com
can you give us the error? Also you have no port on your connection string i.e. new MongoClient('mognodb://localhost:27017') dunno if that will make a difference (no php near to test) but to see just make a "new MongoClient()" without the param.

Sam Millman

unread,
Jan 10, 2013, 12:50:56 PM1/10/13
to mongod...@googlegroups.com
Wait if it never gets the catch block then it is dying before before all that, can you give us an error?

Gary Dryden

unread,
Jan 10, 2013, 1:05:31 PM1/10/13
to mongod...@googlegroups.com
you're right.
I didn't have the port number.
I just presumed php would connect to the default port 27017, but i must specify it completely.
Works as expected now.
thanks

Gary Dryden

unread,
Jan 10, 2013, 1:22:02 PM1/10/13
to mongod...@googlegroups.com
so i changed the line to
    $m = new MongoClient("mongodb://$dbhost:27017");

and it worked.

So my questions is:
why did your test.php file work with no port number 


On Thu, Jan 10, 2013 at 12:00 PM, Derick Rethans <der...@10gen.com> wrote:
Reply all
Reply to author
Forward
0 new messages