PHP has many frameworks, so many times we are confused to choose framework.
Just choosing a framework is still confused ...
... let alone choose a mate .
Serious!
Many are still confused about choosing the framework. Even spend time looking for comparisons between frameworks.
Instead of comparing, we should start learning one of the frameworks.
So that later we can deduce ourselves, which framework is preferred and suitable for us to use.
If it's not suitable ... just search and study the other framework.
It's useless, it's hard to learn, but it's not suitable.
In my opinion:
There is nothing in vain in learning. Because we will get knowledge and experience.
Even if the knowledge cannot be practiced, at least we can teach others.
Okay, continue ...
By the way, what is a framework?
Framework in Indonesian means a framework . Framework for creating something (web).
* correction typo: without = no
The parable might be like that.
By using the framework, creating a web will be faster than PHP Native. Because we don't need to make everything from scratch.
The framework has provided functions, libraries, and other tools that we need.
One framework that is quite popular in Indonesia is Codeigniter.
What is Codeigniter?
CodeIgniter was first released on February 28, 2006. The last stable version — when this writing was made — is version 3.1.9.
Whereas Codeigniter 4 is still under development. CI 4 is the next generation of CI 3 whose concept is more modern 2 .
Codeigniter is suitable for creating web applications such as:
- News Portal;
- Information Systems;
- Web Startup;
- Company Profile;
- eComerce;
- Blog;
- etc.
Codeigniter advantages
There are several advantages of CodeIgniter (CI) compared to other PHP Frameworks, 3
- Fast performance : Codeigniter is the fastest framework compared to other frameworks. Because it doesn't use template engines and ORM that can slow down the process.
- Configuration is minimal (nearly zero configuration): of course to adjust to the database and the flexibility of routing remains authorized to perform configuration by altering some configuration files such as
database.php
orautoload.php
, but to use CodeIgniter by setting the standard, you just need to change a little on the file in the config folder. - Has many communities : The CI community in Indonesia is quite crowded, the tutorial is easy to find.
- Complete documentation : Codeigniter accompanied by
user_guide
complete documentation. - Easy to learn beginners : For beginners, CI is very easy to learn. Because CI doesn't depend too much on additional tools like composer, ORM, template engine, etc.
Examples of websites developed with CodeIgniter
Make a Codeigniter Project
Steps that must be taken to make a CI project:
- Download CodeIgniter;
- Extract CI into htdocs.
We will get a zip file
CodeIgniter-3.1.9.zip
, extract the file in c:\xampp\htdocs
(XAMPP) or /var/www/html
(on Linux).
After that, change the name
CodeIgniter-3.1.9
to tokobuah
.
Why is the name
tokobuah
?
Because in this project, we will create a website that sells fruit.
Now try opening: http: // localhost / tokobuah /
Congratulations Codeigniter has been installed successfully.
Next, please open with the text editor. Then try to recognize the directory structure.
Know Codeigniter's Directory Structure
This is the Codeigniter directory structure:
There are two important directories in CI:
application
and system
. In addition there are also directories user_guide
and several files. The following is the explanation:-
application
contains all application codes. In this directory we will write all of our application code. -
system
contains core codes from Codeiniter. Don't change anything in this directory. If we want to upgrade the version, we can simply replace this directory with a new one. -
tests
contains code to do unit testing. -
user_guide
contains codeigniter documentation. We can delete this directory when the web is ready. -
.editor_config
contains configuration for the text editor. -
.gitignore
contains a list of files and folders that Gitwill ignore . -
comspoer.json
is a file that contains a description of the project and description of the library used. This file is needed by composer. -
contributing.md
is a file that contains an explanation of how to contribute to the CI project. We can delete this file, if the web has been created. -
license.txt
is a file that contains a license description from CI. -
readme.rst
just like this filecontributing.md
file contains an explanation and information about the CI project. We can also delete this file when the web is finished. -
index.php
is the main file from CI. The file that will be opened the first time when we access the web.
Next, please open the directory
application
and note the directory there.-
cache
contains the cache of the application. -
config
contains application configuration.-
autoload.php
where we define autoload; -
config.php
application configuration; -
constants.php
contains constants; -
database.php
application database configuration; -
doctypes.php
contains definitions for HTML doctype ; -
foreign_chars.php
contains characters and symbols; -
hooks.php
contains hooks configuration ; -
index.html
to prevent direct access; -
memcached.php
to contain the configuration for memcached; -
migration.php
configuration for migration; -
mimes.php
contains file type definitions; -
profiler.php
configuration for profilers; -
routers.php
where we write the application route; -
smileys.php
contains code for emojis; -
user_agents.php
contains definitions for user agents .
-
-
controller
contains the code for the controller. -
core
contains code for custom cores. -
helpers
contains helper functions. -
hooks
contains the code for the hook script . -
language
contains strings for languages, if the web supports multilingual. -
libraries
contains a library. -
logs
contains logs from the application. -
models
contains the code for the model. -
thrid_party
contains libraries from third parties. -
views
contains code for view. -
index.html
html file to prevent direct access.
Welcome to Codeigniter
This is the initial display that we will see when we first install CI.
As a warm up, try to change the text
Welcome to CodeIgniter!
to Selamat datang di Toko Buah Petanikode
.
How:
Open file
application/views/welcome_message.php
. Then change the text on the line 71
.
Congratulations
This is the first change you make.
Explanation:
Files
welcome_message.php
that are in a directory views
are files that are responsible for displaying something. Here we can write code for templates and CSS.
Files
welcome_message.php
be loaded by a controller application/controllers/welcome.php
with the code:public function index()
{
$this->load->view('welcome_message');
}
The controller
welcome
is the default controller used. This can be seen in the configuration routers at application/config/routers.php
.
0 Komentar untuk "Codeigniter Tutorial # 1: Introduction to CodeIgniter for Beginners"
Silahkan berkomentar sesuai artikel