Skip to content

mikedfunk/Base-CodeIgniter-App

Repository files navigation

Build Status

Base CodeIgniter App

A starting point CodeIgniter App filled with useful goodies.

Setup

  1. Clone or download
  2. Set the following directories to writable:
    1. application/cache
    2. application/logs
    3. application/db_cache
    4. public/assets/cache

That's it! No submodules because they are a pain.

Usage

  • MY_Controller does a ton of cool stuff:
    • autoload views by saving them as controller_name/method_name.php or define a custom view as $this->view = 'my_view' or skip the view with $this->view = false;
    • views are loaded into layouts (templates) stored in views/layouts. The default layout is application.php. You can change it inside a controller method with $layout = 'layout_name'. or skip the layout with $layout = false;
    • autoload models by saving them as controller_name_model.php. It gets loaded as $this->controller_name.
    • filters are functions run before and after controller output. Set them via public $before_filters = array('method_1', 'method_2');. They take the same params that your controller method does. The point is that you can run them for all but certain methods, only certain methods, or a mix between. Great for authentication!
    • auto migrate to latest version. To enable, uncomment $this->_migrate(); in application/core/MY_Controller.php
  • MY_Model lets you greatly reduce necessary model methods, allow validation in the model, enable observers. Check out the source for details, there's too much to explain here.
  • Presenters to clean up views dramatically
  • REST_Controller to authenticate, format, and present errors properly
  • Pigeon and API_Router for RESTful routing
  • Updated MY_Migration. You can set the migration table in application/config/migration.php
  • MY_Form_validation for a prefix and suffix for each form error. Set it in application/config/form_validation.php
  • All public stuff such as index.php and assets goes in /public/
  • Add a Composer package by editing /composer.json, then run php composer.phar install on the command line from the root directory.

But wait, there's more!

  • Jamie Rumbelow's REST_Controller to output in various formats, throttle, authenticate, return API manifest, add debug info, etc. Extend it, set $this->data, and you're done! You can also set $this->status_code to a 3-digit number and $this->respond(); to just send a status back
  • caching fragments available via the fragment library, repeating partial views via the partial helper
  • Using MY_Log to fix chmod issues
  • Includes Sparks with the following sparks:
    • assets - for easy combining, minifying, and caching of js/css and parsing LESS and CoffeeScript
    • curl - makes curl codeignitery
    • events - event-driven development
    • query string helper - makes working with query-string heavy apps much easier
    • REST client - to interact with RESTful APIs
  • Includes Kenji's CIUnit for unit testing of models, controllers, helpers, libraries. Unit test examples are in tests/folder_name. There is a working controller test in tests/controllers/welcome_Test.php
  • Twitter Bootstrap for easy, responsive, beautiful, customizable, cross-browser UI goodness.
  • API exception handler and manifest library to return formatted API help (both in application/libraries/api)
  • .htaccess from HTML5 Boilerplate with CodeIgniter stuff to remove index.php
  • main config and database config are separated into folders for four typical development environments. I usually add environment setting logic based on the HTTP_HOST in index.php.
  • Includes FirePHP

Change Log

2.0.1

  • Added FirePHP library
  • Added example for Selenium functional test thanks to Phil Palmieri's examples
  • Added examples for model, helper, and library tests
  • Updated Twitter Bootstrap to 2.2.0
  • Show profiler by default if in development environment and it's not an ajax request
  • Added autoload sparks line
  • Better gitignore

2.0.0

  • Added most things above. No need to repeat the entire README again :) .

1.1.2

  • Updated submodules

1.1.1

  • Updated Twitter Bootstrap to 2.0.2
  • Removed copyright statements from docblocks
  • Updated all relevant docblocks to @version 1.1.2

1.1.0

  • Support for travis-ci
  • Updated db config

About

Preconfigured and adds a variety of useful submodules.

Resources

Stars

Watchers

Forks

Packages

No packages published