Fork me on GitHub

What is Propel?

Propel is an open-source Object-Relational Mapping (ORM) for SQL-Databases in PHP 5.4. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.

But not only plain ORM but it also provides database schema migration, reverse engineering of existing database and much more.

Why Propel?

Propel gives you, the web application developer, the tools to work with databases in the same way you work with other classes and objects in PHP without writing SQL.

  • Propel is blazing fast!
  • Propel gives your database a well-defined API.
  • Propel is well documented.
  • Propel comes with common behaviors.

How does it work?!

Everything starts with a xml file. The schema.xml.

<?xml version="1.0" encoding="UTF-8"?>
<database name="bookstore" defaultIdMethod="native">
  <table name="book" phpName="Book">
    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
    <column name="title" type="varchar" size="255" required="true" />
    <column name="isbn" type="varchar" size="24" required="true" phpName="ISBN"/>
    <column name="author_id" type="integer" required="true"/>
    <foreign-key foreignTable="author">
      <reference local="author_id" foreign="id"/>
  <table name="author" phpName="Author">
    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
    <column name="first_name" type="varchar" size="128" required="true"/>
    <column name="last_name" type="varchar" size="128" required="true"/>
If you have already a database with tables, you can use reverse engineering to generate the XML automatically.


Table Schema from Migration With the migration feature of Propel you can update database's schema automatically based on your xml file. This keeps the database up to date without the hassle of writing own ALTER TABLE' SQLs.

Retrieving Data

After building your PHP classes from the xml file you can use those to retrieve data from the database.


$books = BookQuery::create()  // retrieve all books ...
  ->filterByPublishYear(2009) // ... published in 2009
  ->orderByTitle()            // ... ordered by title
  ->joinWith('Book.Author')   // ... with their author

foreach($books as $book) {
  echo  $book->getId() . ': ' . $book->getAuthor()->getFullName();

Manipulate Data

Beside your *Query classes you'll get also active-record classes for your objects after the building.


// manipulate existing
$book = BookQuery::create()->findPK(123); // retrieve a record from a database
$book->setTitle('Don\'t be Hax0red!'); // modify. Don't worry about escaping
$book->save(); // persist the modification to the database

// create new
$book = new Book();
$book->setTitle('JavaScript, The Good Parts.');
$book->save();  // add new row
$book->getId(); // now available since it's autoIncrement

Get It!

Via Composer

"require": {
    "propel/propel": "2.0.0-alpha2"

All releases at

All releases at

Dive In!

Propel uses PDO as an abstraction layer, and code generation to remove the burden of runtime introspection. Therefore Propel is fast.

Propel implements all the key concepts of mature ORM layers: the ActiveRecord pattern, validators, behaviors, table inheritance, reverse engineering an existing database, nested sets, nested transactions, lazy loading, LOB, you name it.

Propel is built for developers who need to keep control of their code:

  • Extensibility is at the heart of Propel's design; whatever you need to customize, Propel allows you to do so in a snap.
  • Propel can get out of your way for when you need custom queries or hyper-optimized transactions.
  • If you need to change your RDBMS in the course of the project, rebuild your model and you're ready to go. Propel supports MySQL, PostgreSQL, SQLite, MSSQL, and Oracle.
  • The code generated by Propel is well commented, IDE-friendly and easy to use.
  • The Propel project started in 2005, and already powers thousands of websites. Thoroughly documented, backed by many tutorials across the web, it also benefits from an enthusiast community that provides rapid support for both beginner and hardcore developers.

Propel is released under the MIT license. It's free to use, even in commercial applications.

Do you want to know more? Jump to the Documentation tab, or start exploring the code in the GitHub repository.

Propel ECG (Build Status)

Propel is strongly unit tested. Propel is developed under Continuous Integration and with a Test Driven Development approach. We use Travis-CI to automatically build our projects, and here are the statuses:

Propel 1.7