Skip to content

My CodeIgniter starter kit with basic needed libraries to start a new CI application.

License

Notifications You must be signed in to change notification settings

bkader/ci-starter-kit

Repository files navigation

CodeIgniter Starter Kit (Demo)

What is this?

Because I am a huge fan of CodeIgniter, I made a small collection of needed resources and put them all together into a single brute project that I simply copy then edit to start developing a CI-based web application.

How to use?

All you have to do is to copy all files, or the one you need, to your workspace and do tiny modifications and configuration.

What is included?

  • HMVC structure using wiredesignz extension.
  • Automatic detection of your base_url that you can change to use your own (see).
  • .htaccess so you would never see index.php on your URLs.
  • Encryption key automatically generated and stored in application/encryption_key.php file (see how it's done).
  • My own Theme Library with two (2) themes included (Bootstrap and Semanti UI) and it is so easy to add yours.
  • Laraval static routing.
  • Some libraries: Bcrypt, Markdown.
  • All modules can have their own admin aria by simply adding an admin controller to them (*application/modules/MODULE/controllers/Admin.php). This controller should extend Admin_Controller in which you have to set your own checking logic.
  • Controllers that require a logged in user should simply extend User_Controller instead of MY_Controller and don't forget to add your checking logic as well.
  • A dummy module is added so you simply copy-paste it and keep only folders that you need then create your files.
  • A very useful hook is added: compress.php that will simply compress your HTML output when you set your environment to production.
  • Instead of calling Form validation library on a method that requires it, I have added a method with optional rules array that you can use as a shortcut. See the method: prepare_form()

How to use prepare_form() method?

Let us say in my Users controller, I have a login() method that has a username and a __password__fields with some rules. This is how my code should look like:

class Users extends MY_Controller
{
    // Site login page.
    public function login()
    {
	    // I start by prepare the form validation.
	    $this->prepare_form(array(
		    // Username field.
		    array(
			    'field' => 'username',
			    'label' => 'Username',
			    'rules' => 'required'
		    ),
		    // Password field.
		    array(
			    'field' => 'password',
			    'label' => 'Password',
			    'rules' => 'required|min_length[8]'
		    )
	    ));
	     
	    // Now I prepare form fields.
	    $this->data['username'] = array(
		    'name'        => 'username',
		    'id'          => 'username',
		    'placeholder' => 'Username',
		    'value'       => set_value('username')
	    );
	    $this->data['password'] = array(
		    'type'        => 'password',
		    'name'        => 'password',
		    'id'          => 'password',
		    'placeholder' => 'Password',
		    'value'       => set_value('Password')
	    );
	     
	    // I proceed to form validation now.
	    if ($this->form_validation->run() == FALSE)
	    {
		    $this->theme->title('Login');
		    $this->theme->load('login', $this->data);
	    }
	    else
	    {
		    // Proceed to login after collecting data.
	    }
	    
    }
}

In my view file that I named login.php (here without any styling):

<?php echo form_open('login'); ?>
    <?php echo form_input($username); ?>
	<?php echo form_input($password); ?>
	<?php echo form_submit('login', 'Login'); ?>
</form>

Credits

All credits go to their respective owners! And a little bit for me for doing this with so much love.

About

My CodeIgniter starter kit with basic needed libraries to start a new CI application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages