FAQ
We plan web project (accounting software) using PHP for web frontend and
MongoDB as database. Also, there will be probably mobile aps for iPhone and
Android, possible REST API and more. We need to write middle layer over raw
database ("model" in desing pattern MVC or MVP) with as much shared
functionality as possible. What is smart way to write middle layer in such
a scenario ?

Options we are considering:

1) Write middle layer as PHP library. Plus: super easy connection to PHP
frontend, but not so great for other use-cases (mobile aps, REST
API...). Also not so great for security and isolation.

2) Write middle layer as server-side executed code<http://www.mongodb.org/display/DOCS/Server-side+Code+Execution#> on
MongoDB server. But they are too many limits limits (db.eval() write lock,
one shard only) as well as it seems it not recommended usage of this
MongoDB functionality. I was looking for MongoDB extensions which would
extend server-side code execution capabilities, but found none.

3) Write middle layer as independent web service, for example in PHP,
python or Node.js. Main problem which I see - MongoDB communicate in BSON.
Many middle layer functions would do simple MondoDB query. Than they would
have to re-encode result in some other serialization standard (since BSON
is MongoDB specific) and then send results to client - which seems to me
like big waste.

Unless we find better solution, we will probably go for variant 1), but any
advice would be really appreciated.

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
mongodb-user+[email protected]
See also the IRC channel -- freenode.net#mongodb

Search Discussions

  • Sam Millman at Nov 27, 2012 at 8:11 am
    The second point is not really server-side but more that it runs within the
    inbuilt JS engine that comes with MongoDB. As you state this would be a
    terrible way to do this.

    The third point wouldn't be so bad, making a single point of entry using
    PHP or something you would just communicate to it using JSON and the PHP
    driver to MongoDB would do the hard work for you, no need to worry about
    BSON. However there are massive security flaws with it, one being that you
    would need to open an interface which accepts MongoDB queries directly, as
    such this interface immediately is a black hole in security even if
    "secured".

    In my opinion your not even better off going with the first point since
    that determines that you must write your own library. Instead I would go
    for a PHP framework like Kohona or Lithium or Yii. Something like that
    would probably be your best bet.

    On 27 November 2012 07:30, Štěpán Kabele wrote:

    We plan web project (accounting software) using PHP for web frontend and
    MongoDB as database. Also, there will be probably mobile aps for iPhone and
    Android, possible REST API and more. We need to write middle layer over raw
    database ("model" in desing pattern MVC or MVP) with as much shared
    functionality as possible. What is smart way to write middle layer in such
    a scenario ?

    Options we are considering:

    1) Write middle layer as PHP library. Plus: super easy connection to PHP
    frontend, but not so great for other use-cases (mobile aps, REST
    API...). Also not so great for security and isolation.

    2) Write middle layer as server-side executed code<http://www.mongodb.org/display/DOCS/Server-side+Code+Execution#> on
    MongoDB server. But they are too many limits limits (db.eval() write lock,
    one shard only) as well as it seems it not recommended usage of this
    MongoDB functionality. I was looking for MongoDB extensions which would
    extend server-side code execution capabilities, but found none.

    3) Write middle layer as independent web service, for example in PHP,
    python or Node.js. Main problem which I see - MongoDB communicate in BSON.
    Many middle layer functions would do simple MondoDB query. Than they would
    have to re-encode result in some other serialization standard (since BSON
    is MongoDB specific) and then send results to client - which seems to me
    like big waste.

    Unless we find better solution, we will probably go for variant 1), but
    any advice would be really appreciated.

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to [email protected]
    To unsubscribe from this group, send email to
    mongodb-user+[email protected]
    See also the IRC channel -- freenode.net#mongodb
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to [email protected]
    To unsubscribe from this group, send email to
    mongodb-user+[email protected]
    See also the IRC channel -- freenode.net#mongodb
  • Jm at Nov 27, 2012 at 12:47 pm
    You could create a PHP library which you would use directly in your PHP web
    frontend. Then you could also make additional services/interfaces
    (REST/alternative web frontend/XML/JSON/whatever) as simple wrappers around
    that library. That way most of your DB access code is contained in one
    library, and you don't have the extra middle layer roundtrip in your PHP
    frontends.

    On Tuesday, November 27, 2012 9:30:50 AM UTC+2, Štěpán Kabele wrote:

    We plan web project (accounting software) using PHP for web frontend and
    MongoDB as database. Also, there will be probably mobile aps for iPhone and
    Android, possible REST API and more. We need to write middle layer over raw
    database ("model" in desing pattern MVC or MVP) with as much shared
    functionality as possible. What is smart way to write middle layer in such
    a scenario ?

    Options we are considering:

    1) Write middle layer as PHP library. Plus: super easy connection to PHP
    frontend, but not so great for other use-cases (mobile aps, REST
    API...). Also not so great for security and isolation.

    2) Write middle layer as server-side executed code<http://www.mongodb.org/display/DOCS/Server-side+Code+Execution#> on
    MongoDB server. But they are too many limits limits (db.eval() write lock,
    one shard only) as well as it seems it not recommended usage of this
    MongoDB functionality. I was looking for MongoDB extensions which would
    extend server-side code execution capabilities, but found none.

    3) Write middle layer as independent web service, for example in PHP,
    python or Node.js. Main problem which I see - MongoDB communicate in BSON.
    Many middle layer functions would do simple MondoDB query. Than they would
    have to re-encode result in some other serialization standard (since BSON
    is MongoDB specific) and then send results to client - which seems to me
    like big waste.

    Unless we find better solution, we will probably go for variant 1), but
    any advice would be really appreciated.
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to [email protected]
    To unsubscribe from this group, send email to
    mongodb-user+[email protected]
    See also the IRC channel -- freenode.net#mongodb
  • Paul Aan at Nov 27, 2012 at 1:10 pm
    You should try MongoDB + Symfony2. It's great for me at all.

    On Tue, Nov 27, 2012 at 7:47 PM, jm wrote:

    You could create a PHP library which you would use directly in your PHP
    web frontend. Then you could also make additional services/interfaces
    (REST/alternative web frontend/XML/JSON/whatever) as simple wrappers around
    that library. That way most of your DB access code is contained in one
    library, and you don't have the extra middle layer roundtrip in your PHP
    frontends.


    On Tuesday, November 27, 2012 9:30:50 AM UTC+2, Štěpán Kabele wrote:

    We plan web project (accounting software) using PHP for web frontend and
    MongoDB as database. Also, there will be probably mobile aps for iPhone and
    Android, possible REST API and more. We need to write middle layer over raw
    database ("model" in desing pattern MVC or MVP) with as much shared
    functionality as possible. What is smart way to write middle layer in such
    a scenario ?

    Options we are considering:

    1) Write middle layer as PHP library. Plus: super easy connection to PHP
    frontend, but not so great for other use-cases (mobile aps, REST
    API...). Also not so great for security and isolation.

    2) Write middle layer as server-side executed code<http://www.mongodb.org/display/DOCS/Server-side+Code+Execution#> on
    MongoDB server. But they are too many limits limits (db.eval() write lock,
    one shard only) as well as it seems it not recommended usage of this
    MongoDB functionality. I was looking for MongoDB extensions which would
    extend server-side code execution capabilities, but found none.

    3) Write middle layer as independent web service, for example in PHP,
    python or Node.js. Main problem which I see - MongoDB communicate in BSON.
    Many middle layer functions would do simple MondoDB query. Than they would
    have to re-encode result in some other serialization standard (since BSON
    is MongoDB specific) and then send results to client - which seems to me
    like big waste.

    Unless we find better solution, we will probably go for variant 1), but
    any advice would be really appreciated.
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to [email protected]
    To unsubscribe from this group, send email to
    mongodb-user+[email protected]
    See also the IRC channel -- freenode.net#mongodb


    --
    Hoài Ân
    Skype: mrgluexv
    0903744334

    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to [email protected]
    To unsubscribe from this group, send email to
    mongodb-user+[email protected]
    See also the IRC channel -- freenode.net#mongodb
  • Marc Schwering at Nov 29, 2012 at 7:56 pm
    Since you are looking for a thin layer, having php experience and off
    course need some security. I would say lithium is definitely an option for
    you.
    Very helpful community support via irc and lot of MongoDB experience too.

    Additionally, a REST Interface is super easy to implement in lithium.

    On Tuesday, November 27, 2012 8:30:50 AM UTC+1, Štěpán Kabele wrote:

    We plan web project (accounting software) using PHP for web frontend and
    MongoDB as database. Also, there will be probably mobile aps for iPhone and
    Android, possible REST API and more. We need to write middle layer over raw
    database ("model" in desing pattern MVC or MVP) with as much shared
    functionality as possible. What is smart way to write middle layer in such
    a scenario ?

    Options we are considering:

    1) Write middle layer as PHP library. Plus: super easy connection to PHP
    frontend, but not so great for other use-cases (mobile aps, REST
    API...). Also not so great for security and isolation.

    2) Write middle layer as server-side executed code<http://www.mongodb.org/display/DOCS/Server-side+Code+Execution#> on
    MongoDB server. But they are too many limits limits (db.eval() write lock,
    one shard only) as well as it seems it not recommended usage of this
    MongoDB functionality. I was looking for MongoDB extensions which would
    extend server-side code execution capabilities, but found none.

    3) Write middle layer as independent web service, for example in PHP,
    python or Node.js. Main problem which I see - MongoDB communicate in BSON.
    Many middle layer functions would do simple MondoDB query. Than they would
    have to re-encode result in some other serialization standard (since BSON
    is MongoDB specific) and then send results to client - which seems to me
    like big waste.

    Unless we find better solution, we will probably go for variant 1), but
    any advice would be really appreciated.
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to [email protected]
    To unsubscribe from this group, send email to
    mongodb-user+[email protected]
    See also the IRC channel -- freenode.net#mongodb

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmongodb-user @
categoriesmongodb
postedNov 27, '12 at 7:38a
activeNov 29, '12 at 7:56p
posts5
users5
websitemongodb.org
irc#mongodb

People

Translate

site design / logo © 2023 Grokbase