Developing Web Apps with Symfony2, Doctrine and       MongoDB
Who Am I?• Software   Engineer at TechJini Solutions• Working    with PHP/Symfony for last 4 years• @kertz   on Twitter an...
The Whys?• Why   Symfony2?• Why   Doctrine?
Symfony2• Made   of reusable components•Acommunity that built Doctrine, Behat, Composer, Assetic and more• Thebackbone for...
Doctrine• Highly   configurable• Supports        MySQL, PgSQL, Oracle, SQlite, MongoDB and CouchDB• Doctrine   Query Language
Installation• ComposerDependency Manager (http:// getcomposer.org)$ curl -s http://getcomposer.org/installer | php$ php co...
Adding MongoDB                                           composer.json{    "require": {        "doctrine/mongodb-odm-bundl...
Configuration                                                config.ymldoctrine_mongodb:    connections:        default:    ...
Bundles• Why   Bundles?• Creating   your own bundles $ app/console generate:bundle
Register Bundles               AppKernel.php
What are we building?•A   simple image sharing app• Store/Retrieve   images in/from GridFS• Allow   comments for images
The Document schema for images                            Image.php
Controller for uploading images                            ImageController.php
The template for uploading images                                new.html.twig
Retrieving the images                   ImageController.php
In Retrospect•A   form to upload an image and add caption• Store   images in MongoDB with GridFS• Retrieve   images• That ...
The Document schema for comments                         Comment.php
Add a reference to comments                              Image.php
Controller for comments                          ImageController.php
Viewing comments for images                        ImageController.php               comments.html.twig
In Retrospect (again)• Allow   comments for image• Show    comments for images by id
Repositories & DQL• Create   custom repositories• Using   Doctrine Query Builder
Repository for comments                 CommentRepository.php
Set repository location                          Comment.php
Calling Repository functions                        CommentController.php
Bundles to watch• SonataAdminBundle       http://github.com/sonata-project/SonataAdminBundle• FOSUserBundle   http://githu...
The End. Questions?
Upcoming SlideShare
Loading in...5
×

Mongo db bangalore 2012

5,192

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
5,192
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Mongo db bangalore 2012"

    1. 1. Developing Web Apps with Symfony2, Doctrine and MongoDB
    2. 2. Who Am I?• Software Engineer at TechJini Solutions• Working with PHP/Symfony for last 4 years• @kertz on Twitter and Github
    3. 3. The Whys?• Why Symfony2?• Why Doctrine?
    4. 4. Symfony2• Made of reusable components•Acommunity that built Doctrine, Behat, Composer, Assetic and more• Thebackbone for future versions of Drupal & phpBB
    5. 5. Doctrine• Highly configurable• Supports MySQL, PgSQL, Oracle, SQlite, MongoDB and CouchDB• Doctrine Query Language
    6. 6. Installation• ComposerDependency Manager (http:// getcomposer.org)$ curl -s http://getcomposer.org/installer | php$ php composer.phar create-project symfony/framework-standard-edition sf-mongo 2.1.x-dev
    7. 7. Adding MongoDB composer.json{ "require": { "doctrine/mongodb-odm-bundle": "3.0.*" }, "minimum-stability": "dev"}$ composer.phar update doctrine/mongodb-odm-bundle AppKernel.php
    8. 8. Configuration config.ymldoctrine_mongodb: connections: default: server: mongodb://localhost:27017 options: {} default_database: sfmongo document_managers: default: auto_mapping: true
    9. 9. Bundles• Why Bundles?• Creating your own bundles $ app/console generate:bundle
    10. 10. Register Bundles AppKernel.php
    11. 11. What are we building?•A simple image sharing app• Store/Retrieve images in/from GridFS• Allow comments for images
    12. 12. The Document schema for images Image.php
    13. 13. Controller for uploading images ImageController.php
    14. 14. The template for uploading images new.html.twig
    15. 15. Retrieving the images ImageController.php
    16. 16. In Retrospect•A form to upload an image and add caption• Store images in MongoDB with GridFS• Retrieve images• That was quick, wasn’t it?
    17. 17. The Document schema for comments Comment.php
    18. 18. Add a reference to comments Image.php
    19. 19. Controller for comments ImageController.php
    20. 20. Viewing comments for images ImageController.php comments.html.twig
    21. 21. In Retrospect (again)• Allow comments for image• Show comments for images by id
    22. 22. Repositories & DQL• Create custom repositories• Using Doctrine Query Builder
    23. 23. Repository for comments CommentRepository.php
    24. 24. Set repository location Comment.php
    25. 25. Calling Repository functions CommentController.php
    26. 26. Bundles to watch• SonataAdminBundle http://github.com/sonata-project/SonataAdminBundle• FOSUserBundle http://github.com/FriendsOfSymfony/FOSUserBundle• FOQElasticaBundle http://github.com/Exercise/FOQElasticaBundle
    27. 27. The End. Questions?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×