Propel

From Lazer

Jump to: navigation, search

Home site

Install Propel with MySQL and Ubuntu install

  1. Install PEAR
    1. Use Synaptic type in "php-pear"
  2. Install php5-xsl for the xslt error not to show.
    1. Use Synaptic type in "php5-xsl"
  3. Install Phing 2.X
    1. pear channel-discover pear.phing.info
    2. pear install phing/phing
  4. Install Creole 1.x
    1. pear channel-discover pear.phpdb.org
    2. pear install phpdb/creole
    3. pear install phpdb/jargon
  5. Install Propel packages
    1. pear channel-discover pear.phpdb.org
    2. pear install phpdb/propel_generator
    3. pear install phpdb/propel_runtime
  6. Create schema.xml file
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

<database name="<project name>" defaultIdMethod="native">

 <table name="book" description="Book Table">
  <column name="book_id" type="integer" primaryKey="true" autoIncrement="true" required="true" description="Book Id"/>
  <column name="title" type="varchar" size="255" required="true" description="Book Title"/>
  <column name="isbn" type="varchar" size="24" required="true" phpName="ISBN" description="ISBN Number"/>
  <column name="publisher_id" type="integer" required="true" description="Foreign Key for Publisher"/>
  <column name="author_id" type="integer" required="true" description="Foreign Key for Author"/>
  <foreign-key foreignTable="publisher">
   <reference local="publisher_id" foreign="publisher_id"/>
  </foreign-key>
  <foreign-key foreignTable="author">
   <reference local="author_id" foreign="author_id"/>
  </foreign-key>
 </table>

 <table name="publisher" description="Publisher Table">
  <column name="publisher_id" type="integer" required="true" primaryKey="true" autoIncrement="true" description="Publisher Id"/>
  <column name="name" type="varchar" size="128" required="true" description="Publisher Name"/>
 </table>

 <table name="author" description="Author Table">
  <column name="author_id" type="integer" required="true" primaryKey="true" autoIncrement="true" description="Author Id"/>
  <column name="first_name" type="varchar" size="128" required="true" description="First Name"/>
  <column name="last_name" type="varchar" size="128" required="true" description="Last Name"/>
 </table>
</database>

  1. Create build.properties file
# The name of the project 
propel.project = <project name>
 
# The database driver 
propel.database = mysql

# The connection parameters (optional)
propel.database.url = mysql://<username>:<password>@localhost/<project name>
#
  1. Create runtime-conf.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>

<config>
 <propel>
  <datasources default="<project name>">
   <datasource id="<project name>">
    <!-- the Propel adapter will usually be the same as phptype of connection DSN -->
    <adapter>mysql</adapter>
    <connection>
     <phptype>mysql</phptype>
     <database><project name></database>
     <hostspec>localhost</hostspec>
     <username><username></username>
     <password><password></password>
    </connection>
   </datasource>
  </datasources>
 </propel>
</config>
  1. Place schema.xml, runtime-conf.xml and build.properties files in the home directory where your project (php files) is.
  2. Create the Database <project name> manually.
  3. Enter "propel-gen <full absolute path to your project>"
  4. Enter "propel-gen <full absolute path to your project> insert-sql"
  5. Create a php file in your project directory like below
<?php
   require_once 'propel/Propel.php';

   Propel::init("<full absolute path to your project>/bookstore/build/conf/bookstore-conf.php");

   echo "Propel is working!!!";
?>
  1. Run you php file and see if it runs correctly.
  2. Copy the build/bookstore to <full absolute path to your project>.
Current Projects