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.
application/config/database.php
.$ composer require rougin/combustor --dev
Wildfire
and Doctrine ORM
or both:$ vendor/bin/combustor install:wildfire
$ vendor/bin/combustor install:doctrine
create:layout
Creates a new header and footer file.
--bootstrap
- includes the Bootstrap tags$ vendor/bin/combustor create-layout --bootstrap
create:controller
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
create:model
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
create:view
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
create:scaffold
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:
delete($table, $delimiters = [])
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]);
find($table, $delimiters = [])
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]);
get_all($table, $delimiters = [])
Returns all rows from the specified table
$table
- name of the database table$delimiters
- delimits the list of rows to be returned
keyword
- used for searching the data from the storageper_page
- defines the number of rows per pageas_dropdown($description)
- returns the list of rows that can be used in form_dropdown()
description
- the field to be displayed in the result (the default value is description
)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.
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.