0

First question so please excuse any formalities I miss.

I am developing a system - the backend in Python, the frontend in PHP. The system will leverage a MongoDB database for a number of reasons. I plan to use an Object Document Mapper to make database lookups, and relationships, between pieces of data relatively trivial.


Adding this information as requested

The plan I envision is that the PHP interface would allow users to view the data, and navigate through to connected information, leveraging the relationship defined in the database. For example

Organisation > IP Ranges > IPs > TCP ports open on this IPs

The Python side is the system collecting this information, entering it into the database, and defining/establishing the relationship between the data (i.e. this IP range belongs to this organisation)


I can see that there are many options for both PHP, and Python, independently - but there dont appear to be any solutions that support both PHP and Python at the same time. Is there a way I can utilise the same ODM across both languages to ensure that data can be referenced/'looked up' in the same manner - or, is there a better solution for this that I am unaware of?


perhaps the simplified version of the question is - is there a language agnostic way I can/should be querying data, with defined relationships in that data, with mongodb?


Thanks! :-)

  • 1
    I don't get your setup. Why not just use PHP or just use Python? Why mix them? Or create an API in one that any other application/layer can use. – M. Eriksson Sep 23 '20 at 10:55
  • Apologies for not being clear - I am looking to be able to make the same queries/leverage the same relationships across the data, in both languages. My assumption would be that I cant use one ODM for PHP, and another for Python, and expect it to work? – user14326830 Sep 23 '20 at 10:56
  • But why have you split the application up like that? If you're using PHP as "front end" (what ever you mean by that since PHP is a service side language), then PHP shouldn't make queries to Mongo. That data should come from the "back end" (Python). If you edit the question to include a bit more details regarding your setup, it might be easer to answer/give suggestions. – M. Eriksson Sep 23 '20 at 10:57
  • Ok - excuse my incorrect use of terminology. I will leverage the PHP application to display data, and show relationships between data (so therefore, needs to be able to query said data), while the Python application will need to add the data to the MongoDB instance and define the relationships through the ODM – user14326830 Sep 23 '20 at 10:59
  • I've edited - hopefully it's clearer – user14326830 Sep 23 '20 at 11:06
  • perhaps the simplified version of the question is - is there a language agnostic way I can/should be querying data, with defined relationships in that data, with mongodb? My assumption was that an ODM was the best way to do this, but happy to be steered in a better direction – user14326830 Sep 23 '20 at 11:11
  • One solution would be, as I've already mentioned, create an API (in Python) which interacts with the database. Basically a micro service. Then when you need something in PHP, you call that API. That way, you can still show what you want in PHP while you have one single layer that interacts with a database. Another solution would be to use Python to present the data as well. – M. Eriksson Sep 23 '20 at 11:25
  • 1
    that actually seems to be a very sensible idea - I'll pursue that avenue instead. Thank you! – user14326830 Sep 23 '20 at 11:28
  • "Language agnostic way" is MQL, MongoDB query language. – D. SM Sep 23 '20 at 12:29

0 Answers0