PHP Classes
elePHPant
Icontem

Zodeken - Code generator for Zend Framework: Generate code to access MySQL with Zend Framework

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   Screenshots Screenshots   View files View files (37)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2012-09-06 (2 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 435 All time: 5,805 This week: 647Up
Version License PHP version Categories  
zodeken 1.4.0GNU Lesser Genera...5.2PHP 5, Databases, Libraries, Code Gen...
Description Author  

This package can generate code to access MySQL with Zend Framework.

It can generate Controllers for CRUD actions, Db_Tables, Mappers and Forms classes to manipulate records of MySQL tables using the zf command line tool based on db settings in the application.ini file of your project.

Validators and filters are added to the form automatically depending on the field's data types.

It can detect table relationships and adds methods to access related database table records.

Picture of Nguyen Duc Thuan
Name: Nguyen Duc Thuan <contact>
Classes: 2 packages by
Country: Viet Nam Viet Nam
Age: 28
All time rank: 24698 in Viet Nam Viet Nam
Week rank: 1570 Up11 in Viet Nam Viet Nam Down
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
*** FEATURES ***

- Supports only MySQL.

- Generates Controllers with CRUD actions, Db_Tables, DbTable_Rows, DbTable_Rowsets 
with DocBlock tags that gives you autocompletion when coding in an IDE.

- Defines Db_Table's $_dependentTables and $_referenceMap following InnoDB's
relationships.

- Adds some commonly used methods to Db_Table: fetchPairs (an array of
key => value pairs), fetchOne (value of first column's first field), fetchOnes
(an array that is a list of fetchOne).

- You are free to add custom methods to Db_Table, Row, Rowset, Form or Mapper.
Basic methods like fetchOne(), fetchPairs(), fetchOnes(), setters, getters...
are added to abstract classes of them. Those abstract class files will be
overwritten when you re-run the generator.

With forms, latest Zodeken-generated classes will be put in
(Application_)Form_Edit[TableName]_Latest, you can compare this with current
version (Application_)Form_Edit[TableName] to add or change the code as
necessary to it.

- Detects the relationships between the tables and generates basically necessary
methods.

    One-to-many:
        $memberRow->getPostRowsetByAuthorId()
        $postRow->getMemberRowByAuthorId()

    Many-to-many:
        $tagRow->getPostRows()
        $postRow->getTagRows()

- Uses proper form element for each data type. For example:
    enum/set -> radio
    varchar/char -> text
    text/longtext -> textarea
    foreign key -> select
    ...

- Adds validators and filters depending on data type of the field. For example:

    InArray for ENUM/SET
    Int for INT
    Float for BIGINT/DECIMAL/FLOAT
    ->setRequired(true) for 'NOT NULL' fields
    StringLength(array('max' => 100)) for fields that have 100 char. limit

- Adds a drop-down list for a foreign key field to the form:

    $tableCategory = new Application_Model_Category_DbTable();
    $this->addElement(
        $this->createElement('select', 'category_id')
            ->setLabel('Category Id')
            ->setMultiOptions(array("" => "- - Select - -")
                + $tableCategory->fetchPairs())
            ->setRequired(true)
            ->setDecorators($this->elementDecorators)
    );

*** INSTALLATION ***

1. Download latest version from http://code.google.com/p/zodeken/downloads/list

2. Place the folder Zodeken into a folder that covered by your include_path
setting. Or simply, just place Zodeken into the same folder with your Zend
library, for example:

    /usr/share/php/
        Zend/
        Zodeken/

3. Edit your .zf.ini (usually located at your home folder), append this line:

    basicloader.classes.20 = "Zodeken_ZfTool_ZodekenProvider"

You may change the number 20 to another one that you prefer.

If don't know where that file is located, you may run:

    zf --setup config-file

or

    zf create config

The command 'zf' not found??? Read this first:
http://framework.zend.com/manual/en/zend.tool.framework.clitool.html

4. Done

*** USAGE ***

1. Create the project using zf command line tool

    zf create project zfproject

2. "chdir" to the created project folder

    cd zfproject

3. Configure database settings in the application.ini file

    zf configure db-adapter [...]

4. Run the command

    zf generate zodeken

5. Done

*** TEST ***

1. Create a database

2. Import ZodekenTest.sql

3. Do steps as in "USAGE" section
Screenshots  
  • Screenshot-zf-generate-zodeken.jpg
  Files folder image Files  
File Role Description
Files folder imageZodeken (2 files, 1 directory)
Plain text file CHANGELOG Data Auxiliary data
Accessible without login Plain text file README Doc. Instructions
Plain text file ZodekenTest.sql Data Database for testin Zodeken

  Files folder image Files  /  Zodeken  
File Role Description
Files folder imageZfTool (2 files, 1 directory)
  Plain text file Exception.php Class Class source
  Plain text file Form.php Class Class source

  Files folder image Files  /  Zodeken  /  ZfTool  
File Role Description
Files folder imagetemplates (2 directories)
  Plain text file Exception.php Class Class source
  Plain text file ZodekenProvider.php Class Class source

  Files folder image Files  /  Zodeken  /  ZfTool  /  templates  
File Role Description
Files folder imagebootstrap2 (15 files)
Files folder imagedefault (15 files)

  Files folder image Files  /  Zodeken  /  ZfTool  /  templates  /  bootstrap2  
File Role Description
  Plain text file controller.php Output Sample output
  Plain text file form-latest.php Output Sample output
  Plain text file form.php Output Sample output
  Plain text file mapper.php Output Sample output
  Plain text file output-config.xml Data Auxiliary data
  Plain text file row-abstract.php Output Sample output
  Plain text file row.php Output Sample output
  Plain text file rowset-abstract.php Output Sample output
  Plain text file rowset.php Output Sample output
  Plain text file table-abstract.php Output Sample output
  Plain text file table.php Output Sample output
  Plain text file view-create.php Output Sample output
  Plain text file view-index.php Output Sample output
  Plain text file view-pagination.php Output Sample output
  Plain text file view-update.php Output Sample output

  Files folder image Files  /  Zodeken  /  ZfTool  /  templates  /  default  
File Role Description
  Plain text file controller.php Output Sample output
  Plain text file form-latest.php Output Sample output
  Plain text file form.php Output Sample output
  Plain text file mapper.php Output Sample output
  Plain text file output-config.xml Data Auxiliary data
  Plain text file row-abstract.php Output Sample output
  Plain text file row.php Output Sample output
  Plain text file rowset-abstract.php Output Sample output
  Plain text file rowset.php Output Sample output
  Plain text file table-abstract.php Output Sample output
  Plain text file table.php Output Sample output
  Plain text file view-create.php Output Sample output
  Plain text file view-index.php Output Sample output
  Plain text file view-pagination.php Output Sample output
  Plain text file view-update.php Output Sample output

 Version Control Unique User Downloads Download Rankings  
 97%Total:435All time:5,805
 This week:0This week:647Up