When I get the object id from mongodb that was generated by mongo itself
how can I convert/encode it to base 64 using PHP?
$_newCursor = $this->collection->findOne($urlQuery);
$_id = $_newCursor['_id'];
if you really need to have mongoID in base64 encoded string you need to do this:
$_newCursor = $this->collection->findOne($urlQuery);
$_id = base64_encode((string)$_newCursor['_id']);
Furthermore if you have a MongoID Object you can extract string id with:
$_id = $mongoIdObject->__ToString();