home shape

Getting Started with ArangoDB & Symfony: Part 1 | ArangoDB 2013

This is part 1 (of 4) of an introduction to the use of ArangoDB together with Symfony 2. You'll find the links to the other parts of this tutorial at the end of this text.

In this tutorial we will implement a very simple movie database as an example of how to use ArangoDB together with Symfony 2. We assume for the tutorial that you know the basic concepts of Symfony2. No prior ArangoDB knowledge is required.

The demo shows how to create, edit, update and delete movies, how to select a list of movies from the database in two different ways. We’ll use the simple query API for most examples. The “search for a topic” feature uses ArangoDB’s query language (AQL), a convenient sql-like way to query ArangoDB.

You can download the completed demo at Github.


A short word on ArangoDB

Warning - a paragraph of marketing ahead! ;-) ArangoDB is an open-source mostly-memory database with a flexible data model for documents and graphs for modern web applications.  With ArangoDB you build high performance applications in short time - it is schema-less and has a full-blown query language nevertheless (there is no need to write map/reduce functions if your queries get more complicate) . You can even extend ArangoDB by adding your own Javascript/Ruby methods to the database.

Libraries & infrastructure

The following components are used

What’s this? Since Symfony is a PHP framework we need the PHP driver for ArangoDB. The MopArangoDbBundle integrates the PHP driver into Symfony: having this bundle installed, you can config the connection to ArangoDB in the config.yml (note: the bundle also offers a FOSUserBundle integration which is not used in this demo, but might be interested for you if you are looking for a  user management system out of the box).

Installing ArangoDB

Now grab your copy of ArangoDB from the download page and install it. There are binaries available for many common platforms (Linux, OSX, Windows). Make sure that ArangoDB is up and running by opening the graphical user interface in your browser:

http://localhost:8529/_admin/html/index.html

Configuring Symfony for use with ArangoDB

First thing we have to do is to tell Symfony that we want to work with ArangoDB. So we add the two required bundles to composer.json and run “php composer.phar update” as usual.

// path/to/myapp/composer.json
"require": {
        …
        "triagens/ArangoDb": "dev-devel",
        "mop/arangodbbundle" : "dev-master"
         …
    },

Note: for this tutorial a feature was added to the ArangoDB PHP driver which is only available in the  “dev-devel” branch at the time of writing this text.

Having MopArangodbBundle installed we can add our connection settings to config.yml

//myapp/app/config/config.yml
mop_arango_db:
    default_connection: main #will be set to the first connection if not present
    connections:
        main:
            host: 127.0.0.1
            port: 8529

We are done.

In Symfony we can now access the default connection to ArangoDB with

$connection = $this->get('mop_arangodb.default_connection');

The end

Congrats, you have reached the end of part 1 the tutorial. There is more:

Frank Celler

Frank Celler

Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the CTO and co-founder of ArangoDB. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s NoSQL group & is an active member of NoSQL community.

Get the latest tutorials, blog posts and news: