SlideShare una empresa de Scribd logo
1 de 41
MongoNYC - PHP Development With MongoDB
         Presented By: Fitz Agard - LightCube Solutions LLC

                           May 20, 2010
Introductions - Who is this guy?
{ “name”: “Fitz Agard”,
  “description”: [“Developer”,”Consultant”,”Data Junkie”, “Educator”, “Engineer”],
  “location”: “New York”,
  “companies”:[
        {“name”: “LightCube Solutions”, “url”: “www.lightcubesolutions.com”}
  ],
  “urls”:[
        {“name”: “LinkedIn”, “url”: “http://www.linkedin.com/in/fitzagard”},
        {“name”: “Twitter”, “url”: “http://www.twitter.com/fitzhagard”}
  ],
  “email”: “fhagard@lightcube.us”
}




               (If the above formatting confused you please see - http://json.org/)
Yankee Stadium

 Get People In


Make the Most
 of their Time

Get People Out
     Safely
Web-Based Applications

1. Get Data In

2. Make the most of the data

3. Get the data out safely
Does your
 PHP code
work well with
    this?
How about
  this?
Why PHP Developers Should Use MongoDB?

                    Database Reasons

• Document-oriented storage - JSON-style documents with dynamic
  schemas offer simplicity and power.
• Full Index Support - Index on any attribute.
• Replication & High Availability - Mirror across LANs and WANs.
• Auto-Sharding - Scale horizontally without compromising functionality.
• Querying - Rich, document-based queries.
• Fast In-Place Updates - Atomic modifiers for contention-free
  performance.
• Map/Reduce - Flexible aggregation and data processing.
• GridFS - Store files of any size.
Why PHP Developers Should Use MongoDB?

            PHP Reasons


                          OO
  AD                         P

               UT
    RAD                     AOP
Why PHP Developers Should Use MongoDB?

                           PHP Reasons

                                             Object
             elopm ent                              Orient
                                                           ed
        e Dev                                 Progra
A   gil                                              mming
                                    st ing
                             nit Te
                            U
      Rapid                                   Aspect Oriented
             Aplic
      Deve         ation                       Development
            lopm
                  ent
Why PHP Developers Should Use MongoDB?




The KISS Method
Use Case - eCommerce
Imagine the SQL
 (not PHP) code
 you would have
to write to figure
   out product
      details.
Simple
         and
       Flexible



http://kylebanker.com/blog/2010/04/30/
       mongodb-and-ecommerce/
Mongo and PHP in a Nutshell
                 http://us.php.net/manual/en/book.mongo.php




Common Methods                    Conditional Operators
   •   find()                                     •   $ne
   •   findOne()                                  •   $in
   •   save()                                    •   $nin
   •   remove()                                  •   $mod
   •   update()                                  •   $all
   •   group()                                   •   $size
   •   limit()                                   •   $exists
   •   skip()                                    •   $type
   •   ensureIndex()                             •   $gt
   •   count()                                   •   $lt
   •   ...And More                               •   $lte
                                                 •   $gte
Don’t you find it strange we haven’t
      talked about PHP yet?
Check out all the
  open PHP
   projects!
phpMoAdmin
                         Eric David Benari - support@phpMoAdmin.com




• Nothing to configure - place the moadmin.php file anywhere on your web site
  and it just works!
• Fast AJAX-driven XHTML 1.1 interface operates consistently in every browser!
• Self-contained in a single 90kb file!
• Works on any version of PHP5 with the MongoDB NoSQL database & Mongo
  PHP driver installed and running.
• Option to enable password-protection for one or more users; to activate
  protection, just add the username-password(s) to the array at the top of the file.
• E_STRICT PHP code is formatted to the Zend Framework coding standards +
  fully-documented in the phpDocumentor DocBlock standard.
• Instructional error messages - phpMoAdmin can be used as a PHP-Mongo
  connection debugging tool
• All textareas can be resized by dragging/stretching the lower-right corner.
• Multiple design themes to choose from
• Free & open-source! Released under the GPLv3 FOSS license!
ActiveMongo
                            Cesar D. Rodas- crodas@php.net




• Handle MongoDB connection, connecting once when it is needed
• Define a Collection as a class
• Abstracts iteration over a dataset
• Efficient save() which creates or updates efficiently (using $unset, $set) a document
• Provides simple queries interface
• Use of MongoCollection for complex queries in sub-classes
• Delete current object, Drop() table
• Support filtering per property
• Support for efficient updates on nested documents
• Dynamic References (AKA, save a query to execute later)
Let’s talk about PHP Frameworks that Support MongoDB
Let’s Pick a Framework and Use it with MongoDB
+
• Integrated Unit Testing (speed, quality) [thank you: closures, iterators]
• Aspect Inspired Filter System (flexibility) [thank you: closures, lambdas,
  iterators]
• Document Oriented Data Sources (speed, flexibility) [thank you mongodb]
• Automatic output escaping (quality) [thank you: stream wrappers]
• Extensible plugin support (flexibility) [thank you: namespaces]
• Static Models with Object Oriented Results (speed, flexibility) [thank you: late
  static binding, iterators]
• More, More, More....


                             http://lithify.me
Let’s Make Use of the MVC
Your Connection
Your Connection




                  Use This
Your Connection




                  Not This
Setup Your Model




  This will setup your mongodb collection
Setup Your Views


                   index.html.php




                                    add.html.php
Last But Not Least - The Controller
Yay!
It Worked!
What happens when we need
   to extend our Blog?



     Let’s add a Tag!
Normally we
would touch this!
= Dynamic Schema
Just Change Your Views


                 index.html.php




                                  add.html.php
Just Change Your Views


                 index.html.php




                                  add.html.php
What else can I do with MongoDB and PHP?
Cursors
 MongoDates
                     Indexes                   MapReduce

                ...Just to name a few...
     Sharding
                                           Exceptions

MongoBinData
                                                MongoCode
            MongoRegex
No more time.


            Go here for more:
http://us.php.net/manual/en/book.mongo.php
         http://www.mongodb.org
    http://www.lightcubesolutions.com
              http://lithify.me
{ “type”: “Conclusion”,
  “date”: new Date('05-21-2010'),
  “comments”: [“Thank You”,”Have Fun Developing”],
  “location”: “New York”,
  “speaker”: “Fitz H. Agard”,
  “contact”: “fhagard@lightcube.us”
}

Más contenido relacionado

Destacado

Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdbiammutex
 
Ученическое самоуправление
Ученическое самоуправлениеУченическое самоуправление
Ученическое самоуправлениеlicey1568
 
Pstu change management_plan
Pstu change management_planPstu change management_plan
Pstu change management_planGà Bàng
 
вх об утверждении нормативов
вх об утверждении нормативоввх об утверждении нормативов
вх об утверждении нормативовnslipina
 
оценка конкурентоспособности продукта, содержащего оис
оценка конкурентоспособности продукта, содержащего оисоценка конкурентоспособности продукта, содержащего оис
оценка конкурентоспособности продукта, содержащего оисВиктория Лабецкая
 
Carpenter mattvisualresume
Carpenter mattvisualresumeCarpenter mattvisualresume
Carpenter mattvisualresumemattycarps
 
Learning design overview
Learning design overviewLearning design overview
Learning design overviewMartin Weller
 

Destacado (15)

Ctmt3
Ctmt3Ctmt3
Ctmt3
 
Working Experience
Working ExperienceWorking Experience
Working Experience
 
Patricia Ellen Vazquez
Patricia Ellen VazquezPatricia Ellen Vazquez
Patricia Ellen Vazquez
 
GreenFidic
GreenFidicGreenFidic
GreenFidic
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdb
 
Ученическое самоуправление
Ученическое самоуправлениеУченическое самоуправление
Ученическое самоуправление
 
Pstu change management_plan
Pstu change management_planPstu change management_plan
Pstu change management_plan
 
Thesis
ThesisThesis
Thesis
 
вх об утверждении нормативов
вх об утверждении нормативоввх об утверждении нормативов
вх об утверждении нормативов
 
Bluetooth marketing device bt pusher pro+ with gprs-1
Bluetooth marketing device   bt pusher pro+ with gprs-1Bluetooth marketing device   bt pusher pro+ with gprs-1
Bluetooth marketing device bt pusher pro+ with gprs-1
 
Enermedades infecciosas
Enermedades infecciosasEnermedades infecciosas
Enermedades infecciosas
 
54
5454
54
 
оценка конкурентоспособности продукта, содержащего оис
оценка конкурентоспособности продукта, содержащего оисоценка конкурентоспособности продукта, содержащего оис
оценка конкурентоспособности продукта, содержащего оис
 
Carpenter mattvisualresume
Carpenter mattvisualresumeCarpenter mattvisualresume
Carpenter mattvisualresume
 
Learning design overview
Learning design overviewLearning design overview
Learning design overview
 

Similar a Mongo NYC PHP Development

Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongoDB
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Railsrfischer20
 
MongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDBNorberto Leite
 
MongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDBMongoDB
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FSMongoDB
 
Accra MongoDB User Group
Accra MongoDB User GroupAccra MongoDB User Group
Accra MongoDB User GroupMongoDB
 
Python - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguageTsungWei Hu
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Consjohnrjenson
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
How Different are MongoDB Drivers
How Different are MongoDB DriversHow Different are MongoDB Drivers
How Different are MongoDB DriversNorberto Leite
 
Mongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDBMongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDBJustin Smestad
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - DetroitMartin Gutenbrunner
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharpSerdar Buyuktemiz
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Pierre Joye
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedAlexander Makarov
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 

Similar a Mongo NYC PHP Development (20)

Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-final
 
MongoDB and Ruby on Rails
MongoDB and Ruby on RailsMongoDB and Ruby on Rails
MongoDB and Ruby on Rails
 
MongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB at Gilt Groupe
MongoDB at Gilt Groupe
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
MongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB Tick Data Presentation
MongoDB Tick Data Presentation
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
New paradigms
New paradigmsNew paradigms
New paradigms
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FS
 
Accra MongoDB User Group
Accra MongoDB User GroupAccra MongoDB User Group
Accra MongoDB User Group
 
Python - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming Language
 
MongoDB Pros and Cons
MongoDB Pros and ConsMongoDB Pros and Cons
MongoDB Pros and Cons
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
How Different are MongoDB Drivers
How Different are MongoDB DriversHow Different are MongoDB Drivers
How Different are MongoDB Drivers
 
Mongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDBMongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDB
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 

Mongo NYC PHP Development

  • 1. MongoNYC - PHP Development With MongoDB Presented By: Fitz Agard - LightCube Solutions LLC May 20, 2010
  • 2. Introductions - Who is this guy? { “name”: “Fitz Agard”, “description”: [“Developer”,”Consultant”,”Data Junkie”, “Educator”, “Engineer”], “location”: “New York”, “companies”:[ {“name”: “LightCube Solutions”, “url”: “www.lightcubesolutions.com”} ], “urls”:[ {“name”: “LinkedIn”, “url”: “http://www.linkedin.com/in/fitzagard”}, {“name”: “Twitter”, “url”: “http://www.twitter.com/fitzhagard”} ], “email”: “fhagard@lightcube.us” } (If the above formatting confused you please see - http://json.org/)
  • 3. Yankee Stadium Get People In Make the Most of their Time Get People Out Safely
  • 4. Web-Based Applications 1. Get Data In 2. Make the most of the data 3. Get the data out safely
  • 5. Does your PHP code work well with this?
  • 6. How about this?
  • 7. Why PHP Developers Should Use MongoDB? Database Reasons • Document-oriented storage - JSON-style documents with dynamic schemas offer simplicity and power. • Full Index Support - Index on any attribute. • Replication & High Availability - Mirror across LANs and WANs. • Auto-Sharding - Scale horizontally without compromising functionality. • Querying - Rich, document-based queries. • Fast In-Place Updates - Atomic modifiers for contention-free performance. • Map/Reduce - Flexible aggregation and data processing. • GridFS - Store files of any size.
  • 8. Why PHP Developers Should Use MongoDB? PHP Reasons OO AD P UT RAD AOP
  • 9. Why PHP Developers Should Use MongoDB? PHP Reasons Object elopm ent Orient ed e Dev Progra A gil mming st ing nit Te U Rapid Aspect Oriented Aplic Deve ation Development lopm ent
  • 10. Why PHP Developers Should Use MongoDB? The KISS Method
  • 11. Use Case - eCommerce
  • 12. Imagine the SQL (not PHP) code you would have to write to figure out product details.
  • 13. Simple and Flexible http://kylebanker.com/blog/2010/04/30/ mongodb-and-ecommerce/
  • 14. Mongo and PHP in a Nutshell http://us.php.net/manual/en/book.mongo.php Common Methods Conditional Operators • find() • $ne • findOne() • $in • save() • $nin • remove() • $mod • update() • $all • group() • $size • limit() • $exists • skip() • $type • ensureIndex() • $gt • count() • $lt • ...And More • $lte • $gte
  • 15. Don’t you find it strange we haven’t talked about PHP yet?
  • 16. Check out all the open PHP projects!
  • 17. phpMoAdmin Eric David Benari - support@phpMoAdmin.com • Nothing to configure - place the moadmin.php file anywhere on your web site and it just works! • Fast AJAX-driven XHTML 1.1 interface operates consistently in every browser! • Self-contained in a single 90kb file! • Works on any version of PHP5 with the MongoDB NoSQL database & Mongo PHP driver installed and running. • Option to enable password-protection for one or more users; to activate protection, just add the username-password(s) to the array at the top of the file. • E_STRICT PHP code is formatted to the Zend Framework coding standards + fully-documented in the phpDocumentor DocBlock standard. • Instructional error messages - phpMoAdmin can be used as a PHP-Mongo connection debugging tool • All textareas can be resized by dragging/stretching the lower-right corner. • Multiple design themes to choose from • Free & open-source! Released under the GPLv3 FOSS license!
  • 18. ActiveMongo Cesar D. Rodas- crodas@php.net • Handle MongoDB connection, connecting once when it is needed • Define a Collection as a class • Abstracts iteration over a dataset • Efficient save() which creates or updates efficiently (using $unset, $set) a document • Provides simple queries interface • Use of MongoCollection for complex queries in sub-classes • Delete current object, Drop() table • Support filtering per property • Support for efficient updates on nested documents • Dynamic References (AKA, save a query to execute later)
  • 19. Let’s talk about PHP Frameworks that Support MongoDB
  • 20.
  • 21. Let’s Pick a Framework and Use it with MongoDB
  • 22. +
  • 23. • Integrated Unit Testing (speed, quality) [thank you: closures, iterators] • Aspect Inspired Filter System (flexibility) [thank you: closures, lambdas, iterators] • Document Oriented Data Sources (speed, flexibility) [thank you mongodb] • Automatic output escaping (quality) [thank you: stream wrappers] • Extensible plugin support (flexibility) [thank you: namespaces] • Static Models with Object Oriented Results (speed, flexibility) [thank you: late static binding, iterators] • More, More, More.... http://lithify.me
  • 24. Let’s Make Use of the MVC
  • 26. Your Connection Use This
  • 27. Your Connection Not This
  • 28. Setup Your Model This will setup your mongodb collection
  • 29. Setup Your Views index.html.php add.html.php
  • 30. Last But Not Least - The Controller
  • 31. Yay!
  • 33. What happens when we need to extend our Blog? Let’s add a Tag!
  • 36. Just Change Your Views index.html.php add.html.php
  • 37. Just Change Your Views index.html.php add.html.php
  • 38. What else can I do with MongoDB and PHP?
  • 39. Cursors MongoDates Indexes MapReduce ...Just to name a few... Sharding Exceptions MongoBinData MongoCode MongoRegex
  • 40. No more time. Go here for more: http://us.php.net/manual/en/book.mongo.php http://www.mongodb.org http://www.lightcubesolutions.com http://lithify.me
  • 41. { “type”: “Conclusion”, “date”: new Date('05-21-2010'), “comments”: [“Thank You”,”Have Fun Developing”], “location”: “New York”, “speaker”: “Fitz H. Agard”, “contact”: “fhagard@lightcube.us” }

Notas del editor