Here’s a chunk from the download, I hope its helpful. I’ve not implemented CodeCrafter, but I admire the effort very much. Thanks Crafter.
How it works
——————
You enter the values for the database that you wish to generate code for, press
the Submit button and that’s it!
The CodeCrafter reads the details you supplied and creates the resulting code
under your Code Igniter application directory.
CodeCrafter will generate a directory structure for the generated code and place
the code there. It will refuse to recreate directories that already exist, but you
can overwrite this option.
Starting CodeCrafter
——————————
Invoke the codecrafter method by typing the ffg url in your browser.
http://www.mydomain.com/codecrafter/
or
http://www.mydomain.com/codecrafter/codecrafter/
You will be presented with a form that prompts you for information about your database.
If you wish to generate source for the entre database:
- Enter the server, username, password and database name
- Click the button that say ‘Go ahead. Make my code’
If you wish to generate source for the specific database:
- Enter the server, username, password and database name
- Click the ‘advanced tab’
- Enter the table name
- Click the button that say ‘Go ahead. Make my code’
If you can’t remember what database and tables you have.
- Enter the server, username, password
- Click the ‘advanced tab’
- Click the ‘Fetch tables for me’
- This will query the database for all tables that are available to the specified
user.
- The table name will appear in a new panel to the right of the database info panel
- Click on the databse name you want to work with.
- The database name will be automatically filled in the database info panel
- All tables from your selected database will be displayed in a panel to the right
of the database panel
- Click on the table name you require.
- The database and table name will be automatically filled in the database info panel
- All fiels from your selected table will be displayed in a panel below the database
and table panels
- Set the field specifications as desired.
- Click the button that say ‘Go ahead. Make my code’
Note:
The fetch tables only works for Mysql since CI does not currently offer meta data for
databases.
Setting field options
——————————————
1. Currently, if you wish to customise the field options for selected tables, you can
only do that ONE TABLE AT A TIME. CodeCrafter WILL NOT allow you to customise field
options for more than one table in your selected database at a time. This will be
addressed in a future version.
More on the Advanced Options
——————————————
1. Check the ‘Overwrite Protection’ to prevent CodeCrafter from overwriting existing
directories. FILES IN THE DIRECTORIES WILL BE OVERWRITTEN. Tread carefully.
2. You can now output your generated code to:
* Disk
* Screen
* Both disk and screen
3. The ‘Create Navigator’ option will create a navigation system to allow you to browse
your selected code. This can form the skeleton for your own navigation system.
See http://css.maxdesign.com.au/listamatic/
Using your code
————————
The generated code can be found here (obviously the directory names are configurable):
[ci_system_directory]/application/crud_ouput/
[ci_system_directory]/application/crud_ouput/table_name/
[ci_system_directory]/application/crud_ouput/table_name/controllers/
[ci_system_directory]/application/crud_ouput/table_name/views/
[ci_system_directory]/application/crud_ouput/table_name/models/[[table_name]]
Copy the generated code to your own aplications directory,
Invoke the new controller methods
Enjoy
About the Generated Code
————————————-
Code is generated for the views, controllers and models.
CodeCrafter uses templates to assist with the code generation. The templates can
be found in the CodeCrafters view/template directory (Not the generated code!).
If you wish to change portions of the code, you can do that.
The tenplate uses placeholders in the following format
[[placeholder_name]]
Some of the more abvious ones
- [[component]] - The table name
- [[class]] - The table name with first letter in Caps
- [[modelname]] - The table name with first letter in Caps + ‘model’ appended
- [[primary_key_value]] - PK for the table
- [[table]] - Guess!!
Note:
——-
I have in mind to rationalise and centralise this list of placeholder variables, so they will
probably change in time. So tread carefully of you are playing with them.