Combustor is a Codeigniter library that generates controllers, models, and views based from database tables. It uses the Describe library for retrieving the database tables and as the basis for code generation.
- Generates code based from the structure of the Codeigniter framework
- Speeds up the code development for prototyping web applications
- View templates are based on Bootstrap which can also be modified later
- Needs to worry only on the database schema, and Combustor will do the rest
- Download the Codeigniter framework here and extract it to the web server.
- Configure the application's database connectivity settings in
application/config/database.php
. - Install Combustor through the Composer package manager:
$ composer require rougin/combustor --dev
- Install the ORM wrappers
Wildfire
andDoctrine ORM
or both:
$ vendor/bin/combustor install:wildfire
$ vendor/bin/combustor install:doctrine
Creates a new header and footer file.
--bootstrap
- includes the Bootstrap tags
$ vendor/bin/combustor create-layout --bootstrap
Creates a new HTTP controller.
name
- name of the database table
--camel
- uses camel case naming convention for the accessor and mutators--doctrine
- generates a controller based on Doctrine--keep
- keeps the name to be used--lowercase
- keeps the first character of the name to lowercase--wildfire
- generates a controller based from Wildfire
$ vendor/bin/combustor create:controller users --camel --wildfire
Creates a new model.
name
- name of the database table
--camel
- uses camel case naming convention for the accessor and mutators--doctrine
- generates a controller based on Doctrine--keep
- keeps the name to be used--lowercase
- keeps the first character of the name to lowercase--wildfire
- generates a controller based from Wildfire
$ vendor/bin/combustor create:model users --camel --wildfire
Creates a new view template.
name
- name of the database table
--bootstrap
- includes the Bootstrap tags--camel
- uses camel case naming convention for the accessor and mutators--doctrine
- generates a controller based on Doctrine--keep
- keeps the name to be used--lowercase
- keeps the first character of the name to lowercase--wildfire
- generates a controller based from Wildfire
$ vendor/bin/combustor create:view users --bootstrap
Creates a new HTTP controller, model, and view template.
name
- name of the database table
--bootstrap
- includes the Bootstrap tags--camel
- uses camel case naming convention for the accessor and mutators--doctrine
- generates a controller based on Doctrine--keep
- keeps the name to be used--lowercase
- keeps the first character of the name to lowercase--wildfire
- generates a controller based from Wildfire
$ vendor/bin/combustor create:scaffold users --bootstrap --wildfire
The following methods below are available if --wildfire
is installed:
Deletes the specified data from storage.
$table
- name of the database table$delimiters
- delimits the list of rows to be returned
$this->wildfire->delete('users', ['id' => 3]);
Finds the row from the specified ID or with the list of delimiters from the specified table.
$table
- name of the database table$delimiters
- delimits the list of rows to be returned
$this->wildfire->delete('users', ['id' => 3]);
Returns all rows from the specified table
$table
- name of the database table$delimiters
- delimits the list of rows to be returnedkeyword
- used for searching the data from the storageper_page
- defines the number of rows per page
as_dropdown($description)
- returns the list of rows that can be used inform_dropdown()
description
- the field to be displayed in the result (the default value isdescription
)
result()
- returns the list of rows from the storage in a modeltotal_rows()
- returns the total number of rows based from the result
$delimiters = ['keyword' => 'test', 'per_page' = 3];
$result = $this->wildfire->all('users', $delimiters);
var_dump((array) $result->result());
NOTE: This method is also available if --doctrine
is installed.
-
If either Wildfire or Doctrine is installed, no need to specify it as option for executing a specified command (e.g.
vendor/bin/combustor create:controller --wildfire
). However if both are installed, the command to be executed must have a--wildfire
or--doctrine
option added. -
To learn more about Doctrine's functionalities and its concepts, the documentation page can be found here.
-
Before generating the models, views, and controllers, please make sure that the database is defined properly (foreign keys, indexes, relationships, normalizations) in order to minimize the modifications after the codes has been generated. Also, generate the models, views, and controllers first to tables that are having no relationship with other tables in the database.
- The reason for this is that Combustor will generate controllers, models, and views based on the specified database schema. If there's something wrong in the said database, Combustor will definitely generate a bad codebase.
-
For found bugs or suggestions, feel free to open an issue or create a pull request.
Please see CHANGELOG for more information what has changed recently.
$ composer test
The MIT License (MIT). Please see LICENSE for more information.