Skip to content
No description, website, or topics provided.
PHP Other
  1. PHP 99.1%
  2. Other 0.9%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Silex and MongoDB Workshop

This repository contains an example Silex application, which was used for the Building Your First App with Silex and MongoDB workshop. Abstract follows:

This session will introduce Silex, a PHP micro-frame work based on Symfony2 components, and MongoDB, a non-relational, schema-free document database, as we combine them to build a geo-enabled web application. We’ll explore Silex's routing and controller architecture to start, and then dive into MongoDB's document model, query language, and geospatial features once we start implementing data persistence. Additionally, we will define services in Silex (even micro-frameworks benefit from thin controllers!), take advantage of Twig for templating, and discuss project deployment for both MongoDB and our application.


Clone this repository and install/update dependencies with Composer:

$ git clone git://
$ cd silex-mongodb-workshop
$ composer update

The application also requires that you have MongoDB server and the MongoDB PHP driver installed. Additional resources include:


Customize the application configurations as needed. The repository includes config/dev.php.dist and config/prod.php.dist files, which may be customized by copying each to a new file without a .dist extension and modifying as necessary. Configuration files without .dist are ignored by Git, which makes them suitable to hold private data (e.g. API keys).

The prod configuration file contains parameters for Twitter OAuth (empty by default) and the MongoDB database name (silex by default). The dev config inherits prod, and generally needs no customization.

Importing Data fixtures

Venue data fixtures are included in the repository as venues.json. These must be imported into the appropriate MongoDB collection (silex.venues by default):

$ mongoimport -d silex -c venues --upsert < venues.json

Running the Application

The easiest way to run this application is using the built-in web-server found in PHP 5.4+. The script in the repository can be used to launch this.

Additionally, the Silex documentation discusses various web server configurations if you would like a more permanent solution.

Relevant Resources

The workshop.pdf file included in the project repository serves as an outline for topics covered during the workshop. Additionally, it contains links to many subjects not covered in the slides below, such as importing data from Foursquare and OpenStreetMap.

The Getting Acquainted with MongoDB presentation is available on GitHub. An older version of those slides is also available on Speaker Deck.

Dustin Whittle's Silex: From Micro to Full-stack presentation from Symfony Live London 2013 is available on both YouTube and Speaker Deck.

Additional references for this workshop include:

You can’t perform that action at this time.