Skip to content

romangetman/PropelServiceProvider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PropelServiceProvider

Build Status

The PropelServiceProvider provides Silex integration with Propel

Branching model

  • The 1.x branch contains Propel 1.6 integration.
  • The 2.x branch contains Propel2 integration.

Note: the following instructions are relative to PropelServiceProvider used with Propel2 (branch 2.x). For PropelServiceProvider used with Propel 1, please switch to branch 1.x.

Set up

If you want to use PropelServiceProvider, you will need:

  • Silex 1.x
  • PHP 5.4 or greater
  • Composer

To setup the project in your Silex application, you have to rely on composer ; just add the following to your composer.json file:

"require": {
    "propel/propel-service-provider": "2.x"
}

Then register you model namespace in Composer autoload:

"autoload": {
     "psr-0": { "Your\\Model\\Namespace": "path/of/your/model" }
}

Then install Composer and all dependencies:

wget http://getcomposer.org/composer.phar

php composer.phar install

Parameters

  • propel.config_file (optional): The name of Propel configuration file with full path. Default is /full/project/path/generated-conf/config.php

It's strongly recommanded to use absolute paths for previous option.

Services

No service is provided.

Propel configures and manages itself by using static methods and its own service container, so no service is registered into Application. Actually, the PropelServiceProvider class initializes Propel in a more "Silex-ian" way.

Registering

After you've installed PropelServiceProvider and its dependencies, you can register PropelServiceProvider in your application:

<?php

$app->register(new Propel\Silex\PropelServiceProvider(), array(
    'propel.config_file' => __DIR__.'/path/to/myproject-conf.php'
));

Alternatively, if you built your model with default Propel generator options:

<?php

$app->register(new Propel\Silex\PropelServiceProvider());

We can consider "default" Propel generator options:

  • Put schema.xml files into the main directory project
  • Run vendor/bin/propel model:build command without specify any options about directories and namespace package.

Usage

You'll have to build the model by yourself. According to Propel documentation, you'll need two files:

  • schema.xml which contains your database schema;

  • runtime-conf.xml which contains the database configuration.

Use the vendor/bin/propel script to create all files (SQL, configuration, Model classes).

vendor/bin/propel model:build
vendor/bin/propel config:convert-xml
vendor/bin/propel sql:build
.................

Propel2 documentation can be found here.

About

Propel service provider for Silex.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%