Blog for Learning

| lesson material | material summary | questions and answers | definitions | types and examples | other information | materi pelajaran | ringkasan materi | pertanyaan dan jawaban | definisi | jenis-jenis dan contoh-contoh | informasi lainnya |

Powered by Blogger.

Pages

Codeigniter Tutorial # 1: Introduction to CodeIgniter for Beginners

Codeigniter Learning for Beginners
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 is a PHP framework that uses the MVC design pattern (Model View Controller) 1 .
CodeIgniter was first released on February 28, 2006. The last stable version — when this writing was made — is version 3.1.9.
Codeigniter website
Codeigniter website
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.phpor autoload.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_guidecomplete 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

One of the Indonesian websites that still use CI is projects.co.id.
Projects.coid website

Make a Codeigniter Project

Steps that must be taken to make a CI project:
  1. Download CodeIgniter;
  2. Extract CI into htdocs.
Please open the Codeigniter website to download.
Download Codeigniter
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).
Codeigniter extract
After that, change the name CodeIgniter-3.1.9to tokobuah.
Rename CodeIgniter
Why is the name tokobuah?
Because in this project, we will create a website that sells fruit.
CI Success Installation
Congratulations 🎉Codeigniter has been installed successfully.
Next, please open with the text editor. Then try to recognize the directory structure.
I open it with the VS Code text editor :
Open CodeIgniter in the text editor

Know Codeigniter's Directory Structure

This is the Codeigniter directory structure:
Directory structure for CI projects
There are two important directories in CI: 📁 applicationand 📁 systemIn addition there are also directories 📁user_guideand several files. The following is the explanation:
  1. 📁 applicationcontains all application codes. In this directory we will write all of our application code.
  2. 📁 systemcontains 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.
  3. 📁 tests contains code to do unit testing.
  4. 📁 user_guidecontains codeigniter documentation. We can delete this directory when the web is ready.
  5. 📄 .editor_config contains configuration for the text editor.
  6. 📄 .gitignorecontains a list of files and folders that Gitwill ignore .
  7. 📄 comspoer.jsonis a file that contains a description of the project and description of the library used. This file is needed by composer.
  8. 📖 contributing.mdis 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.
  9. 📖 license.txt is a file that contains a license description from CI.
  10. 📖 readme.rstjust like this file 📄 contributing.mdfile contains an explanation and information about the CI project. We can also delete this file when the web is finished.
  11. 📄 index.phpis the main file from CI. The file that will be opened the first time when we access the web.
Next, please open the directory 📁 applicationand 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.phpcontains definitions for HTML doctype ;
    • 📄 foreign_chars.php contains characters and symbols;
    • 📄 hooks.phpcontains 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.phpcontains definitions for user agents .
  • 📁 controller contains the code for the controller.
  • 📁 core contains code for custom cores.
  • 📁 helpers contains helper functions.
  • 📁 hookscontains 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

When opening http: // localhost / tokobuah / , we will get a Welcome to Codeigniter view .
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.phpThen change the text on the line 71.
Change text welcome
... and now try reloading the page http: // localhost / tokobuah / .
Welcome to Codeigniter
Congratulations 🎉
This is the first change you make.
Explanation:
Files 📄 welcome_message.phpthat are in a directory 📁viewsare files that are responsible for displaying something. Here we can write code for templates and CSS.
Files 📄 welcome_message.phpbe loaded by a controller application/controllers/welcome.phpwith the code:
public function index()
{
    $this->load->view('welcome_message');
}
The controller welcomeis the default controller used. This can be seen in the configuration routers at 📄application/config/routers.php.
Default router
0 Komentar untuk "Codeigniter Tutorial # 1: Introduction to CodeIgniter for Beginners"

Silahkan berkomentar sesuai artikel

 
Template By Kunci Dunia
Back To Top