Codeigniter Preview
Codeigniter Preview
By Krishna Rungta
1. What is CodeIgniter?
2. CodeIgniter Features
3. How CodeIgniter Works?
4. CodeIgniter Release History
1. Application subdirectories
2. System subdirectories
3. User_guide directory
4. Vendor directory
1. Database configuration
2. CodeIgniter Pagination Database Model
3. CodeIgniter Pagination Routes
4. CodeIgniter Pagination Controller
Chapter 12: How to Upload Image & File in CodeIgniter (with Example)
1. What is Laravel?
2. What is CodeIgniter?
3. Why use Laravel?
4. Why use CodeIgniter?
5. Features of Laravel
6. Features of CodeIgniter
7. Laravel vs. CodeIgniter: Know the Difference
8. Laravel vs. CodeIgniter which is better?
Chapter 1: What is CodeIgniter? How
does it Work?
What is CodeIgniter?
CodeIgniter is a PHP MVC framework for developing applications rapidly.
CodeIgniter provides out of the box libraries for connecting to the database
and performing various operations. Like sending emails, uploading files,
managing sessions, etc.
CodeIgniter Features
Let's see some of the features that make CodeIgniter great. The following list
is not exhaustive but gives you an idea of what to expect when working with
CodeIgniter.
Small footprint
The entire source code for CodeIgniter framework is close to 2MB. This
makes it easy to master CodeIgniter and how it works. It also simplifies
deploying and updating it.
Blazing fast
Users tend to favor applications that load very fast. If you have worked with
some of the modern frameworks, then you will realize that they take less
than one second to load just after installation. CodeIgniter,
you can loads on average around less than 50ms. The extra time spent
optimizing like is the case in another framework is freed up when you are
working with CodeIgniter.
Loosely coupled
The built-in features are designed to work independently without relying too
much on other components. This makes it easy to maintain and make
upgrades
MVC Architecture
Excellent documentation:
The framework is well documented, and there are good books, tutorials and
answered forum questions on CodeIgniter. This means whatever challenge
that you have, chances are someone has already encountered the problem,
solved it and the solution is out there for you.
Extendable:
CodeIgniter comes with some libraries, and helpers out of the box. If
what you want is not there or you would like to implement an existing
feature your way. Then you can do so easily by creating your libraries,
helpers, packages, etc.
CodeIgniter is easy to master for anyone who is already familiar with PHP.
Within a very short time, the student can start developing professional
applications using CodeIgniter.
For example, if you want to retrieve a customer with the id= 3, the
controller will receive your request, then request the model to retrieve the
record with the id of 3. The model returns the record to the controller. The
controller then forwards the result to the view which formats it into a
human-readable format. Then the results are returned to the user in the
browser.
Summary
CodeIgniter is a PHP framework for developing applications rapidly
The entire source code for CodeIgniter is close to 2MB. This makes it
easy to master CodeIgniter and how it works
The built-in features of CodeIgniter are designed to work independently
without relying too much on other components
The framework uses the Model-View-Controller architectural design
The framework is well documented, and they are good books, tutorials
and answered forum questions on CodeIgniter CodeIgniter comes with
some libraries, and helpers users out of the box
CodeIgniter is easy to master for anyone who is already familiar with
PHP
In CodeIgniter user requests a resource, the controller responds first.
The controller understands the user request then request the necessary
data if it is important
Chapter 2: How to Download & Install
CodeIgniter + Composer [Configuration
Included]
In this tutorial, we are going to look at how you can install and configure
CodeIgniter. They are two ways of installation CodeIgniter. You can
download the latest version from the CodeIgniter website, or you can use a
tool like a composer to automate the installation
The image below shows the download link to the latest version of the
framework
Step 2) Clicking the above link will download the framework as a zipped
folder. Unzip the contents of CodeIgniter-3.1.10.zip
Step 3) Let's say you want to create a project called the online store. You
can follow the following steps to start your project. Create a new
directory in on your development drive, e.g, D:\Sites\online-store
Step 5) Just to make sure everything is ok, open the terminal and start the
built-in PHP server
cd D:\Sites\ online-store
Run the following command
php -S localhost:3000
http://localhost:3000/
What is Composer?
The composer is a package management system for PHP. A package is simply
a collection of PHP scripts that work together towards a single
goal. Based on this definition, CodeIgniter can even though it's a
framework, qualifies to be labeled a package in composer terminologies.
following command
composer
HERE,
application/config
HERE,
CodeIgniter Configurations
let's now make some of the most common settings in CodeIgniter
Open application/config/config.php
Base URL
$config['base_url'] = '';
Sets the base URL. If its blank then CodeIgniter will set it for you
automatically. If you want to be explicit about your base URL, then you can
use the something like the following
$config['base_url'] = 'http://localhost:3000';
HERE,
Class Prefix
Query Strings
$config['enable_query_strings'] = FALSE;
To
$config['enable_query_strings'] = TRUE;
Other settings
They are many settings that you can set in config.php including date
formats, cache and view paths, etc. much of what you configure depends
on your application needs
example.com/index.php?q=eggs
The URL looks longer and weird. The good thing is you can configure
CodeIgniter to remove that.
Open application/config/config.php
Locate the following line
$config['index_page'] = 'index.php';
Set it to the following
$config['index_page'] = '';
HERE,
Next, we need to create the .htaccess that rewrites the URLs Add a
new file .htacces in the root directory of the application Add the
following code
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
HERE,
The above code is for configuring web servers that run apache server.
The above code basically gets the URI parameters and executes them
via index.php even if it's not showing in the browser URL.
Summary
They are two ways of installation CodeIgniter. You can download the
latest version from the CodeIgniter website, or you can use composer to
automate the installation
The composer is a package management system for PHP
A composer can be used for: Install individual packages, Update existing
packages remove installed packages