Back to articles list
- 3 minutes read

How to Develop a PHP+MySQL Application With Propel and Vertabelo

Propel is a popular ORM (Object-Relational Mapping) library for PHP. Recently, the Vertabelo team started to develop VertabeloPropel, a tool which converts your Vertabelo models into Propel’s schema xml.

If you want to try using Propel with Vertabelo to develop a simple PHP MySQL application, here is how to do it. The following example uses Composer, a PHP tool for handling project dependencies.

Set up Your Project

  1. Create the file composer.json which describes your project dependencies. You will use at least Propel (package propel/propel) and VertabeloPropel (vertabelo/vertabelo-propel) as your project dependencies.

        "name": "Vertabelo/ExampleBookshop",
        "description": "Example Bookshop application",
        "require": {
            "propel/propel": "~2.0@dev",
            "vertabelo/vertabelo-propel": "*@dev"

  2. Run

    composer install

  3. You will see something like this:

    Loading composer repositories with package information
    Installing dependencies (including require-dev)
    Loading composer repositories with package information
    Installing dependencies (including require-dev)

  4. Both Propel and VertabeloPropel are now downloaded into the vendor directory.

Create and Setup Your Database

  1. Create your model in Vertabelo. (If you don’t have your account yet, you can sign up for a free trial here.) Choose MySQL as your database engine:

    Create a new database model for MySQL database

    Here is a sample database model which I prepared earlier:

  2. Download the model as an XML file and save it in your project directory as model.xml.

    Exporting your database model to an XML file in Vertabelo

  3. Create a MySQL database.

    from the command prompt enter:

    create database bookshop;

    or in phpMyAdmin:

  4. In Vertabelo generate the SQL create script. Download the script and save it in your project directory.

    Generating an SQL code for your database model in Vertabelo

  5. Run the SQL create script against your database. Either from the command prompt:

    \. /home/akozubek/propel-example/sql/create.sql

    or in phpMyAdmin:

  6. Create the file propel.yaml describing the location of your MySQL database.

                  adapter: mysql
                  classname: Propel\Runtime\Connection\ConnectionWrapper
                  dsn: "mysql:host=localhost;dbname=bookshop"
                  user: bookshop
          defaultConnection: bookshop
              - bookshop
          defaultConnection: bookshop
              - bookshop

Generate Propel Classes

  1. Generate the Propel schema with VertabeloPropel:


    or in Windows:


  2. Generate the Propel classes:

    vendor/bin/propel model:build

    or in Windows:

    vendor\bin\propel.bat model:build

  3. The generated Propel classes will be in the directory generated-classes. You then have to autoload them. For example, you can do this with composer by adding this entry to your composer.json file:

      "autoload": {
        "classmap": ["generated-classes/"]

    and then executing the command composer dump-autoload.

  4. Convert the propel.yaml file into the config.php file, which you can later include in your PHP files

    vendorbin\propel.bat config:convert


    vendor/bin/propel config:convert

  5. Write your application using Propel classes. Here is the official documentation for your reference:

    You can always take a look at our example bookshop application at the VertabeloPropel GitHub repository.

go to top

Our website uses cookies. By using this website, you agree to their use in accordance with the browser settings. You can modify your browser settings on your own. For more information see our Privacy Policy.