পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Tuesday, February 14, 2017

CodeIgniter - Configuration

After setting up the site, the next thing that we should do is to configure the site. The application/config folder contains a group of files that set basic configuration of your site.

Configuring Base URL

The base URL of the site can be configured in application/config/config.php file. It is URL to your CodeIgniter root. Typically, this will be your base URL, with a trailing slash e.g.
http://example.com/
If this is not set, then CodeIgniter will try to guess the protocol, domain and path to your installation. However, you should always configure this explicitly and never rely on autoguessing, especially in production environments. You can configure the base URL in the $config array with key “base_url” as shown below −
$config['base_url'] = 'http://your-domain.com';

Database Configuration

The database of the site can be configured in application/database.php file. Often we need to set up database for different environment like development and production. With the multidimensional array provided in the CodeIgniter, we can setup database for different environment. The configuration settings are stored in the array as shown below −
$db['default'] = array( 
   'dsn'   => '', 
   'hostname' => 'localhost', 
   'username' => 'root', 
   'password' => '', 
   'database' => 'database_name', 
   'dbdriver' => 'mysqli', 
   'dbprefix' => '', 
   'pconnect' => TRUE, 
   'db_debug' => TRUE, 
   'cache_on' => FALSE, 
   'cachedir' => '', 
   'char_set' => 'utf8', 
   'dbcollat' => 'utf8_general_ci',
   'swap_pre' => '', 
   'encrypt' => FALSE, 
   'compress' => FALSE, 
   'stricton' => FALSE, 
   'failover' => array() 
);
You can leave few options to their default values except hostname, username, password, database and dbdriver.
  • hostname − Specify location of your database here e.g. localhost or IP address
  • username − Set username of your database here.
  • password − Set password of your database here.
  • database − Set name of the database here.
  • dbdriver − Set type of database that you are using e.g. MySQL, MySQLi, Postgre SQL, ODBC, and MS SQL.
By changing the key of the array $db, you can set other configuration of database as shown below. Here, we have set the key to ‘test’ to set the database for testing environment, by keeping the other database environment as it is.
$db['test'] = array( 
   'dsn'   => '', 
   'hostname' => 'localhost', 
   'username' => 'root', 
   'password' => '', 
   'database' => 'database_name', 
   'dbdriver' => 'mysqli', 
   'dbprefix' => '', 
   'pconnect' => TRUE, 
   'db_debug' => TRUE, 
   'cache_on' => FALSE, 
   'cachedir' => '', 
   'char_set' => 'utf8', 
   'dbcollat' => 'utf8_general_ci', 
   'swap_pre' => '', 
   'encrypt' => FALSE, 
   'compress' => FALSE, 
   'stricton' => FALSE, 
   'failover' => array()
);
You can simply switch to different environment by changing the value of a variable as shown below −
$active_group = ‘default’; //This will set the default environment
$active_group = ‘test’; //This will set the test environment

Autoload Configuration

This file specifies, by default, which systems should be loaded. In order to keep the framework as light-weight as possible, only the absolute minimal resources are loaded by default. One should autoload the frequently used system, rather than loading it at local level, repeatedly. Following are the things you can load automatically −
  • Libraries − It is a list of libraries, which should be auto loaded. Provide a list of libraries in an array as shown below to be autoloaded by CodeIgniter. In this example, we are auto loading database, email and session libraries.
$autoload['libraries'] = array('database', 'email', 'session');
  • Drivers − These classes are located in system/libraries/ or in your application/libraries/ directory, but are also placed inside their own subdirectory and they extend the CI_Driver_Library class. They offer multiple interchangeable driver options. Following is an example to autoload cache drivers.
$autoload['drivers'] = array('cache');
  • Helper files − It is a list of helper files, to be autoloaded. Provide a list of libraries in the array, as shown below, to be autoloaded by CodeIgniter. In the given example, we are autoloading URL and file helpers.
$autoload['helper'] = array('url', 'file');
  • Custom config files − These files are intended for use, only if you have created custom config files. Otherwise, leave it blank. Following is an example of how to autoload more than one config files.
$autoload['language'] = array('lang1', 'lang2');
  • Language files − It is a list of language files, which should be auto loaded. Look at the example given below. Provide a list of languages in an array as shown below to be auto loaded by CodeIgniter. Keep in mind that do not include the "_lang" part of your file. For example, "codeigniter_lang.php" would be referenced as array('codeigniter');
  • Models − It is a list of models file, which should be autoloaded. Provide a list of models in an array as shown below to be autoloaded by CodeIgniter. Following is the example of how to auto load more than one models files.
$autoload['model'] = array('first_model', 'second_model');

No comments:

Post a Comment