In This Section

Splint Application Development

Introduction

Splint was ideally designed for the distribution of Packages /Libraries for Back-End components. It has brought about great reduction in re-write Code Igniter compatible code.

However, why not add Applications to the list of things that should be re-distributed and make work far more easier?

Splint achieves this using Splint Application Packages. The application packages are similar to the library packages with a few differences and a couple of additions which are:

  • The value of the type key in the JSON descriptor file is application instead of library.
  • If the type key is set to application, The Splint terminal tool will run some necessary operations for your application package to run properly when installed in a Code Igniter distribution.
  • Application packages should contain the controllers folder and optionally the config/routes.php file, and the config/autoload.php file.

An app is usually given an interface to run (loaded) with the below command.

$this->load->app("vendor/app_name");

This will load the default controller specified in its config/routes.php file or load the controller as matched by the URL for the controller in which the above command was called.

How Does It Work

The concept of Splint Application Package is one which involves carrying out almost completly similar steps as you would when developing you Code Igniter in your Top-Level application directory.

The main difference is that instead of developing the application in the top-level application directory, you'll be developing it in the application/splints/<vendor_name>/<application_name> directory, just as you would when developing a normal Splint package. You'll just be needing a controller folder for obvious reasons and a config/routes.php file as well.

Let's say for example, there is a Splint application called server-health created by a vendor with the username gauntlet, this will make the fully qualified name of the application be guantlet/server-health. As the application name implies, this is an application package that presents certain properties and status (e.g database size, used storage space, server logs, etc.) of the server the application is served from.

The following steps will enable us install and setup the application within Code Igniter.

  1. cd to a Code Igniter Root.
  2. Open your terminal window
  3. Run:
    splint install quantlet/server-health
  4. Create a Controller in your Code Igniter application directory.
  5. Create a function with any name of your choice. I used index(). anything else is also fine.
  6. Write the below in the function you created above:
    $this->load->app("gauntlet/server-health");
  7. Try accessing the Controller with your browser with its qualified URL.
  8. And that's it. that's what it takes to get an application from the Splint store into your Code Igniter distribution.

You can install as many Splint applications as possible and load them in different Controller functions.

NEXT

Other Topics