Welcome to Ignition: the CodeIgniter 4 extension that will give you the fastest and most extensible headstart on your website and web application development projects!
Download and install Ignition and jump on the fast track to a fully functioning CodeIgniter 4 website. Build an entire website application with a menu system, Clean Blog home page banner, footer, blogging system and user management functions within just a few hours.
For a sample website running a stock version of this open source software visit the example implementation here:
en.ignitionbase.williamsonsoftware.com
Attribution:
✩ CodeIgniter 4; CodeIgniter Foundation; https://codeigniter.com; MIT License
✩ Colorlib; Colorlib; https://github.com/colorlibhq/; MIT License
✩ Fontawesome; https://fontawesome.com/; https://fontawesome.com/support; CC 4.0
✩ jQuerry; John Resig; https://jquery.com; CC0
✩ Clean Blog by Bootstrap; Matt Harzewski; http://jekyllthemes.org/themes/clean-blog/; GPL 3.0
✩ Twitter Typeahead.js; Jake Harding; https://github.com/twitter/typeahead.js/; MIT
Simple vs Easy
What is simple is usually easy, what is easy is often not simple. Simplicity and ease should not be confused. Simplicity should be the target which shall increase functional efficiency, but shall not bolster ease to the detriment simplicity. Excessive complexity limits design potentials.
Features List
Ignition gives you the following:
✔ A built-in blogging system that includes the following: Categories; Popular Posts; Authors table; and a Tag Cloud
✔ Extensive multi language support
✔ Fastest path to a Codeigniter 4 website
✔ App security with numerous security hardening modifications
✔ An app control panel for Administrators and logged-in Users
✔ A flexible but not overly complex site theming system
✔ Built in Twitter typeahead bundle
✔ Ignition AutoForm system with RAD (Rapid Application Development) which allows one to create an entire MVC system (Model, View, Control), with database storage with ability to index and edit records with just one file in less than one hour.
✔ User support with user table, user types, user profile record and login/logout capabilities
Instructions
Download Ignition source code from Github by either cloning the repository or go to Download Zip file (usually a button with a download option). For a really quick-start, jump to Getting Started below.
Ignition File Structure
One very important key to knowing your way around Ignition is in learning the layout of the file system. Knowing where your application files are located and how to access and modify them shall be the basis for much of your development work in Ignition.
Ignition is built around a directory structure as follows:
| web/ |
| appCODEUSET | ❮ Directory. Main application directory |
| ci4CODEUSET | ❮ Directory. Codeigniter application files |
| .env | ❮ File. Set environment variables, especially database names and passwords |
| mountassets | ❮ File. A shell script that mounts the web/public/assets dir, giving access to uploads |
| public | ❮ Directory. Public facing directory, designated as document root in Nginx/Apache config |
| writeCODEUSET | ❮ Directory. A directory that contains writable directories for your application |
CODEUSET: This is a code that gets added to program directory names as a security measure. When your website goes live and is moved to a public web server make sure and set this code to a random number and name the above directories using it. IMPORTANT: You must maintain the prefixes as follows: app, ci4, write and upload (in the write directory) - when renaming the directories with the new site code. This code is used to obscure the location of your application files and help reduce the attack surface area within your production web applications. By keeping secret the program directories it becomes more difficult for an attacker to do directory traversal from inside of your app and upload malicious code or access specific files. This code is set in the web/public/index.php file and is repeated in several places. Set the code in the program as a constant in index.php, variable name IGNITIONCD and elsewhere in this file.
Each of the above directories will now be covered.
Directory: appCODEUSET
This directory is the main application directory and contains the following structure:
Config
Ignition
Language
Site
Views
The directories contained in this directory are application specific but should ordinarily be essentially left in tact. In the future, modules added to Ignition such as DNA will go here. The Config directory contains Codeigniter configuration files which have many options for modifying the Codeigniter framework and your Ignition application. A handful of files, the most important files, that must be modified for each application are covered below in the section titled Configure Ignition.
The Ignition directory contains the Ignition framework. It is a good idea to avoid making changes to the files in the Ignition directory if at all possible. That way, as one upgrades the Ignition framework, they may overwrite this directory with a newer version (remember to update the ci4CODEUSET directory also as the Codeigniter and Ignition versions are matched together). The developer is encouraged to get to know what is contained in these directories and files to better understand how Ignition functions.
The Language directory contains the language files for each of the languages you may wish to include in your application. Many of these files link to the default language files within Ignition. For application specific translations it is recommended to modify the config.php and the ignitionbasic.php files in the respective local sub directories. The ignitionbasic.php file can be renamed to the name of your application.
The Site directory contains site specific programs and configuration files. This is where you will configure Ignition for each of your applications as well as add custom modules for your application. The two main files that require modification are SiteConfig.php and SiteConstants.php. See the below section titled Configure Ignition for more information about the Site directory as this is where you may best add site specific modules to your application. These will be added to the Channels directory inside of Site.
The Views directory contains Codeigniter code that is used for the pager functions and error handling. Normally, modification of these files is not going to be required.
Directory: ci4CODEUSET
This directory contains the Codeigniter application. Occasionally you may wish to access this directory in your application development efforts. This will likely not often occur as Codeigniter is a complex library with many internal moving parts that must work together in concert. However, it is fairly frequently a good practice to study this code and view its internal functions to better understand various error messages or issues that you may encounter in your development work. Minor modifications in just a few places must be made to Codeigniter for it to work correctly with Ignition. These are signified by Ignition comments in the CI source code.
Directory: public
This directory was added as a part of the Codeigniter framework and is the document root for the web server, usually Nginx or Apache.
| assets | ❮ a read only mount of the uploads directory (see uploadCODEUSET below, and mountassets script) |
| blogvista | ❮ css and js files related to the blogvista (a theme option in Ignition) |
| css | ❮ css file for Ignition, bootstrap cleanblog |
| fonts | ❮ fonts required by Ignition | | .htaccess | ❮ Codeigniter web server configuration |
| images | ❮ images required for web application design |
| index.php | ❮ Codeigniter index with modifications. MUST MODIFY THIS FILE FOR EACH SITE |
| js | ❮ cleanblog js files |
| robots.txt | ❮ standard search engine robots where you may disallow the search spiders |
| themes | ❮ the majority of the js and css files required by Ignition app |
Directory: writeCODEUSET
This directory contains directories with write permissions required by the web server. You must always carefully plan and set write permissions in directories on a public server, especially those in the program execution path (in this case PHP) which is set and limited in the web server.
| cache | ❮ Codeigniter, web cache (if enabled) |
| debugbar | ❮ Codeigniter, used in debug mode |
| logs | ❮ Codeigniter logging, normally disabled |
| session | ❮ Codeigniter sessions if using file system session system (vs database) |
| uploadCODEUSET | ❮ User content upload. Set in index.php |
GETTING STARTED:
System Requirements: You must be running a suitable web server such as a modern version of Nginx or Apache. You must have installed and working with your web server PHP 8.1 or above. The database you choose must be compatible with the PHP version that you are running (for example 11.6.2-MariaDB). Additionally, PHP requires several extensions in order to function with Ignition. For a Debian based install (including most Ubuntu distributions), see below section titled Install PHP for Ignition.
1) Download the source code as zip or clone the Github repository
2) Move the source code into your web sites, application directory. I like to use /home/web/newsitename.com/web
3) Create two databases, set the passwords and read-in the databases located in the web/mysql directory. See the file named web/.env for the database names and passwords. They are named ignitionbase.sql and ignition_taz.sql. There is a bash script in the web/mysql directory named setupdb which will create the two databases, set the default passwords and populate them with the supplied data. From the command line cd into the mysql directory and run the script ./setupdb
4) Set your web server configuration (usually nginx or apache) to the document root which is web/public and index.php
5) You must set the name of your website domain name in web/appCODEUSET/Site/SiteConfig.php using the SERVERBASENAME variable. For example myignition.com. This must match the name given for your web server. Simply edit the file and input your domain name.
6) Edit and set the web/mountassets scrtipt. In UNIX this script shall mount
read only the web/writeCODEUSET/uploadCODEUSET directory on the web/public/assets directory. This is necessary in order to not allow direct write access to the assets directory. By default this file does nothing. Edit and run this file to mount this directory.
7) Point your browser to http://myignition.com. See Trouble shooting if you receive an error or this does not work. You will also likely need to set this site name in your local hosts file in order for your operating system to identify this domain name. In order to login as super admin go to the login url: http://myignition.com/login and enter the username of admin@myignition.com and password of blank or anything. WARNING: You must please never deploy this site to a public server without setting a password which you may do in the user profile screen. Additionally, you may set the login url to a custom or obscure and hard to guess value, in SiteConstants.php by setting the variable named LOGINURL.
Trouble shooting: issues at this point, unfortunately, are extremely common. They can range the gambit from web server misconfigurations, missing binaries to a database server not properly set up or missing data. Fortunately, there is an eager and supportive community awaiting your questions, which probably have already been answered many times. Type a description of your next issue into your favorite search engine and you will likely find your answer already given and ready for you. This really is your opportunity to learn new stuff!
8) Go to work customizing the default Ignition site, adding your custom banner (web/public/images/site-banner.jpg), menu entries (web/appCODEUSET/Site/MainMenu.php) and home page (web/appCODEUSET/Site/Channels/Home). If you skipped down to GETTING STARTED and you find yourself customizing the Ignition system, please take the additional time to read this entire README file. The time taken will likely save you time and energy in the long run. Learn about how the RAD system called AutoForm can save you a great many programming hours in the future.
Configure Ignition
You will find your web application configurations to be fairly simple and straightforward with Ignition. Most Ignition configuration values are set in the two files named SiteConfig.php and SiteConstants.php, both located in the web/appCODEUSET/Site directory. Also in this directory are other application specific files which you may customize as required as follows: AdminMenu.php; MainLayout.php; and MainMenu.php. As their names imply it should be fairly easy to figure out how they effect the application.
GET RAD WITH AUTOFORM
GET STARTED WITH IGNITION RAD (Rapid Application Development)
Getting started with RAD in Ignition is fun and easy. Use this RAD tool, called AutoForm, to build a fully functioning app with database in just one hour!
With this RAD tool you shall greatly increase your coding productivity by building in minutes what would normally take several hours to complete. Ignition IForm plus AutoForm allows one to make a simple MVC module with a single database table including a record index listing and input form fast and easy.
As your new application module develops your may easily increase functionality by replacing the AutoForm system with the IForm object form methods.
Examples of AutoForm employed within the Ignition Framework include the following:
Asset
Cateogry
UserType
Error Logs
AuthorAdmin
Logins
Tazuserlogin
See web/appCODEUSET/Ignition/Base/BaseController.php for the $baseIChannels array and check out each of these examples to better understand how the AutoForm system functions.
For your application specific AutoForms you will add to a similar array located in web/appCODEUSET/Site/SiteConfig.php. Look in this file for the array named $siteIChannels. There you will find the sample AutoForm already set and waiting which you may modify to suit your application requirements.
public $siteIChannels =[...];
Steps for building a fully functional AutoForm system using just one file that you will customize:
1) Add an array entry in the $siteIChannels array. This will be the name of your AutoForm. Add, for example, 'employees' in this array variable (open and edit the file named web/appCODEUSET/Site/SiteConfig.php):
public $siteIChannels = [
'sample' => 'Site/Channels/Sample/MC/Sample.autoform.php',
'employees' => 'Site/Channels/Employees/MC/Employees.autoform.php'
];
2) Add an entry in the routes located in web/appCODEUSET/Site/Routes/SiteRoutes.php (copy and paste from the sample AutoForm). For example:
$routes->add('employees' . $GLOBALS['KEYCODE'] . '/(:segment)', '\Ignition\AutoForm\MC\Controller::$1');
$routes->add('employees' . $GLOBALS['KEYCODE'] . '/(:segment)/(:any)', '\Ignition\AutoForm\MC\Controller::$1/$2');
$routes->add('employees' . $GLOBALS['KEYCODE'], '\Ignition\AutoForm\MC\Controller::index');
3) Create a new table in your database (default: mysql/ignitionbase.sql). The table structure would include the fields required for your new RAD app module. In the employee example you may wish to create an employees table and include fields such as employee_firstname, employee_lastname, employee_city, employee_state, employee_zip. In summary you may use the mariadb-dump command on the command line:
mariadb-dump ignitionbase > ignitionbase-modify.sql, and edit in the new table using your text editor (edit: ignitionbase-modify.sql). Then read the table back into the running database using the mariadb command, also on the command line:
mariadb ignitionbase < ignitionbase-modify.sql.
4) Build the one file to contain the 3 required elemental areas for an AutoForm. Open the file named Site/Channels/Sample/MC/Sample.autoform.php and change these specifc file areas as required: 1) AutoForm variables, 2) Index array entry
$iIndex = [...] and 3) Form aray entry
$iForm = [...]. Study the forenamed example file for a better understanding of these required areas.
5) Add your new AutoForm module to the RBAC list contained in the SiteConfig.php file. If you do not, the application will return an error, access not authorized. Open web/appCODEUSET/Site/SiteConfig.php. Scroll down to the array titled rbacLoginAdmin. Find the end of the array and add in your new AutoForm, in the example this would be called employees and should match the name set in your Routes. You can usually just copy and paste from another entry, for example the system entry. However, it is very important from a security standpoint to understand the settings in the RBAC entries. See below RBAC Application Security for more information about this key security system.
Now, you may access your new, fully functioning AutoForm by pointing your browser to the name you gave and set in Routes. For example:
http://myignition.com/employees-[KEYCODE]/
KEYCODE is your session key which is generated automatically after you login. In the example given you must login in order to access this new site module system you just added.
Additionally, what makes AutoForm a lasting and extremely useful addition to your development toolbox is the fact that it is built on top of the IForm system. The IForm is an object class for making form systems that maybe directly employed as yet another RAD tool. Examples of the implementation of IForm is in the following Ignition modules: Assets; Author; Blog; Login; Page; and User. Study each of these modules located in the Ignition directory and look for the IForm implementation, usually located in the CI view file which you may find located in the Views subdirectory for each of the named program modules.
IForm will likely become a welcome addition to your application development projects due to its time saving, built-in functions. Furthermore, because AutoForm is built ON TOP of IForm, you may remove all or just portions of your AutoForm system for each module that you create with it. In this way AutoForm is open ended and never a dead end if further customization, expansion or modification is required.
Theme Setup in Ignition
Themes are easily applied to your Ignition application. There are two categories of themes in Ignition, main and app (also called admin). The main themes are those applied to the public website and are usually set in the Site/MainLayout.php file. The app theme file is set by default to Ignition/Base/app-layout.php file. The main theme may be changed at any time by changing the file name set in $mainLayoutFile in the Ignition/Base/BaseController.php file, usually in the constructor of the controller that instantiates the BaseController. Study the built-in modules such as User (located in the Ignition directory) for an implementation example of this feature and setting in the constructor.
The main theme is called by default. This is done automatically when the Codeigniter view is invoked in the controller. The standard CI view is called from the Ignition wrapper function RenderTheme() which incorporates the various theme attributes and security features of Ignition. RenderTheme() is the central calling function to activate and call web pages and applications throughout Ignition. If the controller is to call the app (vs main) function then the variable AppLayout should be set to TRUE. Example from the Ignition Blog controller:
return $this->RenderTheme('form', [
'model' => $model,
'formType' => 'new',
'AppLayout' => true,
'errors' => $model->validationErrors
]);
RBAC Application Security
RBAC Application Security System Greatly Hardens Your Web App Against Malicious Probes
The RBAC system consists of a variable array set in SiteConfig.php that limits controller acces to only those controller names listed in the array. Furthermore, the RBAC system incorporates a global variable named KEYCODE, which is a 25 character random string. This value must be passed in the URL and must match the value stored in the server session values in order to grant access to the called controller. This greatly limits access to only controllers where the KEYCODE is known and supplied by the site visitor. Vulnerable application URLs cannot be called without this code. This greatly limits the attacker's options to only public site URLs and not application URLs.
This entire system is implemented automatically with the exception of having to maintain the arrays in SiteConfig.php that are authorized routes for the application.
Multi-Language Support
Ignition offers two options for providing visitor site support for multiple languages. The two options are as follows: 1) language selection based on locale specific URLs. For example: en.williamsonsoftware.com and es.williamsonsoftware.com. 2) language selection based on SiteConfig->userLocale which can be set based on user preferences (in the user record) or the default site setting in SiteConfig which can be dynamically adjusted based on the visitor's IP address.
If multi language support is not required, simply set the $multiLanguage variable in SiteConfig to FALSE. To set your application to URL based language support set the AUTOLANG constant in SiteConstants to TRUE.
Setting Up Multi-Languages
The two variables to set in SetContants are as follows:
define("AUTOLANG", TRUE); // if true, will determine language based on URL otherwise SiteConfig->userLocale
define("DEFAULTLOCALE", "en"); // default locale, localized language, for site
The two variables to set in SiteConfig are as follows:
public $languages = ['en' => "English", 'es' => "Spanish", 'zh' => "Chinese"]; // this tells ignition which languages to support and provides options on the language selection menu
public $multiLanguage = true; // general setting to turn multi-languages support on and off
HREFLANG Link Support
If multi-language support is activated and AUTOLANG is set to TRUE, then the Ignition layout rendering engine will automatically generate SEO friendly hreflang meta data in the header. This tells the search engines how to locate the various languages for your site based on the locale for each language. This only works when the site is set to option 1, language selection based on locale specific URLs (i.e. AUTOLANG is set to TRUE).
Create a New Igntion Application
In order to create a new Igntion application, you must copy the entire application top level directory structure into a new application directory (see Ignition File Structure above). After you copy all files into a new directory you will need to modify several Codeigniter configuration files. These are located in the web/appCODEUSET/Config directory, as follows:
| Database.php | ❮ Set new database name |
| Session.php | ❮ You may wish to modify your session type (file or database) and timeout length as well as site cookie name |
| Routes.php | ❮ If the Site/Routes/SiteRoutes.php is constrianing, add new routes |
Consult the Codeigniter documentation for more information. You must also set the database name, DBGROUP, and IGNITIONCD in index.php and the basic configuration in SiteConfig.php and SiteConstants.php. See Configure Ignition and Theme Setup in Ignition above.
Install PHP for Ignition
If you are running the wrong version of PHP you may switch between versions using the following instructions to change your distribution to run PHP 8.3, for example:
# modify debian 13 to use php 8.3
apt-get install -y apt-transport-https lsb-release ca-certificates wget
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
apt-get update
apt-get install -y php8.3
You must install several PHP extensions in order to run Ignition
# php and web server related
apt-get install php8.3-xml php8.3-intl php8.3-curl php8.3-gmp
apt-get install php8.3-mysql libaprutil1-dbd-mysql php8.3-http php-memcache php-memcached php8.3-gd php8.3-fpm
apt-get install php8.3-mcrypt php-apcu php8.3-cli php-pear php8.3-mbstring # not available php-fdomdocument php-dompdf
# install certbot in order to add SSL to your web server
apt-get install python3-certbot
apt-get install python3-certbot-nginx
Tips and Tricks
* find command
* write out your program in regular words before coding it
* use nmap at the command line to evaluate running services
* use process list, ps -aux in Linux, to look for running processes