rougin/combustor

CRUD generator for the Codeigniter framework.

v1.2.4 2018-04-18 04:55 UTC

This package is auto-updated.

Last update: 2024-04-14 18:21:41 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

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.

Features

  • 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

Installation

  1. Download the Codeigniter framework here and extract it to the web server.
  2. Configure the application's database connectivity settings in application/config/database.php.
  3. Install Combustor through the Composer package manager:
$ composer require rougin/combustor --dev
  1. Install the ORM wrappers Wildfire and Doctrine ORM or both:
$ vendor/bin/combustor install:wildfire
$ vendor/bin/combustor install:doctrine

Commands

create:layout

Creates a new header and footer file.

Options

  • --bootstrap - includes the Bootstrap tags

Example

$ vendor/bin/combustor create-layout --bootstrap

create:controller

Creates a new HTTP controller.

Arguments

  • name - name of the database table

Options

  • --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

Example

$ vendor/bin/combustor create:controller users --camel --wildfire

create:model

Creates a new model.

Arguments

  • name - name of the database table

Options

  • --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

Example

$ vendor/bin/combustor create:model users --camel --wildfire

create:view

Creates a new view template.

Arguments

  • name - name of the database table

Options

  • --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

Example

$ vendor/bin/combustor create:view users --bootstrap

create:scaffold

Creates a new HTTP controller, model, and view template.

Arguments

  • name - name of the database table

Options

  • --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

Example

$ vendor/bin/combustor create:scaffold users --bootstrap --wildfire

Wilfire's Methods

The following methods below are available if --wildfire is installed:

delete($table, $delimiters = [])

Deletes the specified data from storage.

Arguments

  • $table - name of the database table
  • $delimiters - delimits the list of rows to be returned

Example

$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.

Arguments

  • $table - name of the database table
  • $delimiters - delimits the list of rows to be returned

Example

$this->wildfire->delete('users', ['id' => 3]);

get_all($table, $delimiters = [])

Returns all rows from the specified table

Arguments

  • $table - name of the database table
  • $delimiters - delimits the list of rows to be returned
    • keyword - used for searching the data from the storage
    • per_page - defines the number of rows per page

Returned methods

  • as_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 model
  • total_rows() - returns the total number of rows based from the result

Example

$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.

Reminders

  • 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.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see LICENSE for more information.