Getting started with MongoDB and PHP... Series is out

Hey folks - the first two articles in this PHP Quickstart are out… I’d love to get your feedback.

I’ve started with the basics of getting your environment set up… Then I continue with the basics of CRUD operations with PHP/MongoDB.

Next, I’ll be publishing a sample application where we put these things into practice. Stay tuned for that… also let me know what you’d like to see covered in future articles!

Thanks!

2 Likes

Curious… what should be next in the series?

  • Aggregation Framework with the PHP Driver?
  • Change Streams
  • A usable sample, example app?

Any suggestions?

What a coincidence! Just as I was looking for a guide for using PHP with MongoDB, this was published a few days before I found it!

Its a good and comprehensive introduction, thanks. I had to adjust this, to use a Docker container for the PHP (and Apache) server, rather than on a local Mac machine.

I published my working / final image to Docker Hub:

redswitch/php-mongodb:8.0-1.9.0

(PHP 8.0 with MongoDB client 1.9.0)

Can I ask how you would insert a related / linked document? 2 collections, with a 1-to-Many relationship between them.

I dont know where to start. I expect I will need to query the parent collection to get the object ID, then use that as 1 of the fields / properties in an InsertOne() request?

Is it possible to use a simple PHP variable containing the object ID in the same way as just a String variable?

2 Likes