PHP Class ' mongoclient ' not Found

Source: Internet
Author: User
Tags mongoclient mongodb version php class
The latest Php_mongodb.dll extension for php7.0.4 is installed under Windows for the current official version, which is 1.1.6, supports the highest version MongoDB3.2, supports php7.0, and can see MongoDB extension in Phpinfo ,
However, if you do not use a namespace, new Mongoclient () has the following error
Fatal error:uncaught error:class ' mongoclient ' not found in e:\ .... Why is this?? Excuse me

Version support such as (note mongodb1.1 that line)
1. Extended Support for MongoDB version


2. Extended Support for PHP version


Reply to discussion (solution)

No, not really.

But how do you know there must be a mongoclient class?
You need at least
Print_r (Get_extension_funcs (' MongoDB '));
Take a look at the functions that are available in the extension
Print_r (Get_declared_classes ());
See if there is a class name that you need (or similar) in a predefined class

Php.net's official documents are so used. New Mongoclient ()
I also do not know whether there is this kind, is not I do not install the corresponding VC?
What is the download address of Vc14, how to find it on the Internet

@xuzuning

Didn't I ask you to see it?
Is it so hard at hand?

Array
(
[0] = mongodb\bson\fromphp
[1] = mongodb\bson\tophp
[2] = Mongodb\bson\tojson
[3] = Mongodb\bson\fromjson
)
Array
(
[0] = StdClass
[1] = Exception
[2] = Errorexception
[3] = Error
[4] = ParseError
[5] = TypeError
[6] = Arithmeticerror
[7] = Divisionbyzeroerror
[8] = Closure
[9] = Generator
[Ten] = Closedgeneratorexception
[One] = DateTime
[[] = Datetimeimmutable
[+] = Datetimezone
[+] = DateInterval
[[] = Dateperiod
[+] = logicexception
[+] = badfunctioncallexception
[+] = badmethodcallexception
[+] = domainexception
[+] = InvalidArgumentException
[+] = lengthexception
[] = Outofrangeexception
[All] = RuntimeException
[] = OutOfBoundsException
[+] = OverflowException
[+] = rangeexception
[+] = underflowexception
[+] = unexpectedvalueexception
[+] = Recursiveiteratoriterator
[+] = Iteratoriterator
[+] = Filteriterator
[+] = Recursivefilteriterator
[+] = Callbackfilteriterator
[+] = Recursivecallbackfilteriterator
[+] = Parentiterator
[+] = Limititerator
[PNS] = Cachingiterator
[+] = Recursivecachingiterator
[All] = Norewinditerator
[+] = Appenditerator
[+] = Infiniteiterator
[All] = Regexiterator
[+] = Recursiveregexiterator
[[] = Emptyiterator
[Recursivetreeiterator] =
[+] = Arrayobject
[+] = Arrayiterator
[+] = Recursivearrayiterator
[+] = Splfileinfo
[[] = Directoryiterator
[Wuyi] = Filesystemiterator
[Recursivedirectoryiterator] = =
[+] = Globiterator
[Wu] = splfileobject
[+] = Spltempfileobject
[+] = Spldoublylinkedlist
[[+] = Splqueue
[+] = Splstack
[Splheap] = +
[Up] = Splminheap
[+] = Splmaxheap
[+] = Splpriorityqueue
[+] = Splfixedarray
[+] = Splobjectstorage
[All] = Multipleiterator
[[+] = reflectionexception
[Reflection] = =
[Reflectionfunctionabstract] = +
[[+] = reflectionfunction
[[] = Reflectiongenerator
[[+] = Reflectionparameter
[Reflectiontype] =
[Reflectionmethod] =
[About] = Reflectionclass
[[] = Reflectionobject
[] = Reflectionproperty
[All] = Reflectionextension
[+] = reflectionzendextension
[+] = Sessionhandler
[+] = __php_incomplete_class
[Bayi] = Php_user_filter
[[+] = Directory
[Assertionerror] = =
[+] = ziparchive
[+] = Libxmlerror
[[+] = domexception
[All] = Domstringlist
[Domnamelist] = =
[Domimplementationlist] = =
[+] = Domimplementationsource
[Domimplementation] =
[Domnode] = =
[[] = Domnamespacenode
[94] = Domdocumentfragment
[Up] = DOMDocument
[+] = Domnodelist
[$] = Domnamednodemap
[98] = Domcharacterdata
[About] = Domattr
[+] = DomElement
[101] = Domtext
[102] = Domcomment
[103] = Domtypeinfo
[104] = Domuserdatahandler
[[+] = Domdomerror
[106] = Domerrorhandler
[107] = Domlocator
[108] = Domconfiguration
[109] = Domcdatasection
[+] = Domdocumenttype
[111] = Domnotation
[Domentity] = +
[113] = Domentityreference
[All] = Domprocessinginstruction
[+] = Domstringextend
[Domxpath] =
[117] = Pdoexception
[118] = PDO
[119] = Pdostatement
[+] = Pdorow
[121] = SimpleXMLElement
[122] = Simplexmliterator
[123] = XMLReader
[124] = XMLWriter
[Pharexception] = =
[126] = Phar
[127] = Phardata
[+] = Pharfileinfo
[129] = Curlfile
[Finfo] = =
[131] = Mongodb\driver\command
[PPI] = Mongodb\driver\cursor
[133] = Mongodb\driver\cursorid
[134] = Mongodb\driver\manager
[135] = Mongodb\driver\query
[136] = Mongodb\driver\readconcern
[137] = Mongodb\driver\readpreference
[138] = Mongodb\driver\server
[139] = Mongodb\driver\bulkwrite
[+] = Mongodb\driver\writeconcern
[141] = Mongodb\driver\writeconcernerror
[142] = Mongodb\driver\writeerror
[143] = Mongodb\driver\writeresult
[144] = Mongodb\driver\exception\logicexception
[145] = Mongodb\driver\exception\runtimeexception
[146] = Mongodb\driver\exception\unexpectedvalueexception
[147] = Mongodb\driver\exception\invalidargumentexception
[148] = Mongodb\driver\exception\connectionexception
[149] = Mongodb\driver\exception\authenticationexception
[[] = Mongodb\driver\exception\sslconnectionexception
[151] = Mongodb\driver\exception\writeexception
[] = Mongodb\driver\exception\bulkwriteexception
[153] = mongodb\driver\exception\executiontimeoutexception
[154] = Mongodb\driver\exception\connectiontimeoutexception
[155] = Mongodb\bson\binary
[156] = Mongodb\bson\javascript
[157] = Mongodb\bson\maxkey
[158] = Mongodb\bson\minkey
[159] = Mongodb\bson\objectid
[+] = Mongodb\bson\regex
[161] = Mongodb\bson\timestamp
[162] = Mongodb\bson\utcdatetime
[163] = Mysqli_sql_exception
[164] = Mysqli_driver
[165] = Mysqli
[166] = mysqli_warning
[167] = Mysqli_result
[168] = mysqli_stmt
[169] = SoapClient
[[+] = Soapvar
[171] = SoapServer
[172] = SoapFault
[173] = Soapparam
[174] = SoapHeader
[175] = SQLite3
[176] = sqlite3stmt
[177] = Sqlite3result
[178] = Xsltprocessor
)
It's just a few of those related to MongoDB.

Find the reason, because the old version of the Php_mongo.dll is to use the Mongoclient class to achieve the connection, the new version of the Php_mongodb.dll is to use Mongodb\driver\manager to connect; Notice that the class namespace cannot be omitted.
This is an older version of the reference document http://php.net/manual/zh/book.mongo.php
This is the new version of the reference document http://php.net/manual/zh/book.mongodb.php
Here's how to use the new version:

$con    = new Mongodb\driver\manager (' mongodb://127.0.0.1:27017 '); $query  = new Mongodb\driver\query ([]); $ cursor = $con->executequery (' Databasename.collectionname ', $query); $it     = new Iteratoriterator ($cursor); $it- >rewind (); while ($doc = $it->current ()) {Print_r ($doc); $it->next (); Echo '
';}
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.