How to have eclipse resolve php classes in MongoDB\BSON namespace?

风流意气都作罢 提交于 2019-12-13 15:17:43

问题


After many comes and goes I managed to install the MongoDB Driver for PHP 5.6 and made it work on OSX El Capitan. (The way it worked was using Homebrew)

To start working on a project I created the folder for the project and using Composer installed the required packages I needed. Between theese packages I required mongodb/mongodb which is the recomended mongo php library to use by the php Manual on line and in the driver github page.

The problem I found is that Eclipse is resolving the classes in the \MongoDB\ namespace but not in the \MongoDB\BSON\ namespace. If I check what Composer installed in the vendor folder I am able to see that the \MongoDB\BSON\ classes in fact are missing. On the other hand if I run the program in the PHP included webserver, it executes as expected.

So my question is how can do or what am I missing for Eclipse to find the missing classes. Are they defined somewhere else?

If this is not possible because they are compiled into a binary library and I have no way to resolve them, Is there any way to have Eclipse not showing these particular classes as mistakes?

Example of class that runs ok in the webserver, but is highlighted as an error in Eclipse:

$fecha_creacion  = new MongoDB\BSON\UTCDateTime();

回答1:


Reading this post and not finding anything newer on the subject I arrived to the conclusion that developers of the driver don't provide the php sources and leave it to the IDE developers to provide STUBs for the different fuctions of the driver in a way the IDE can recognize the functions and provide syntax checking and documentations popups.

Following this question, I finally ended up finding a JetBrains GitHub where there are many different stubs for PHPStrom, this one among them.

So I copied the file and added it to my project as part of the sources. And that solved my problem.



来源:https://stackoverflow.com/questions/45316371/how-to-have-eclipse-resolve-php-classes-in-mongodb-bson-namespace

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!