codeigniter-composer-boilerplate
A boilerplate for getting started with latest CodeIgniter using Composer.
Getting started
Only follow these steps:
-
Install Composer.
-
Clone or download the CodeIgniter source code.
-
Edit the
./index.php
root file and add the composer autoloader:
// Composer autoload (add this line before CodeIgniter core)
require_once __DIR__ . '/vendor/autoload.php';
require_once BASEPATH.'core/CodeIgniter.php';
- Create a
composer.json
file in the root. This file is for your third-party packages that you want to use.
{
"description": "My first application",
"require": {
"php": ">=5.5"
}
}
Testing the configuration
- For example, install GImage package:
composer require joseluisq/gimage
- In your
application/controllers/Welcome.php
add these lines:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use GImage\Image;
class Welcome extends CI_Controller {
public function index()
{
// This code will output a Github image in your browser.
$url = 'https://assets-cdn.github.com/images/modules/logos_page/Octocat.png';
$avatar = new Image();
$avatar->load($url)->output();
}
}
- Run your server and navigate.