Skip to main content

Codeigniter installation & setup: Codeigniter Club

               

Windows Environment 

  1.  Install XAMPP or WAMP 
  2.  Download and Unzip the package from Codeigniter.com 
  3.  Extract all the documents in the server space (htdocs or www directory)
Linux Environment 
  1. Download and Unzip the package from Codeigniter.com 
  2. Place the extracted folder in /var/www (in WAMP) or xampp/htdocs (XAMPP)
Base URL 
  1. Go to application/config/config.php 
  2. Define base URL as $config['base_url'] = 'http://localhost/path/to/folder';
How to remove index.php from URL?
  1. go to root 
  2. create htaccess file 
  3. Add below code inside it 
RewriteEngine on RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Note: .htaccess code varies depending on the hosting server. Some hosting servers (e.g.: Godaddy) need to use an extra? in the last line of the above code. The following line will be replaced with the last line in applicable case: 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Nginx Configuration
  1. Open nginx config file (by default: /etc/nginx/sites-available/default) 
  2. Add below code inside it.
server { server_name domain.tld; root /path-to-codeigniter-folder; //you codeigniter path index index.html index.php; # set expiration of assets to MAX for caching location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { expires max; log_not_found off; } location / { # Check if a file or directory index file exists, else route it to index.php. try_files $uri $uri/ /index.php; } location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; include fastcgi.conf; } }

Database Configuration

  1. Go to application/config/database.php 
  2. Set the following configuration variables.

  • Host  
  • Username 
  • Password 
  • Database Name 
  • Port 

Set Default Controller

  1. Go to application/config/routes.php 
  2. set the following configuration variable value with your controller name. (default_controller)

AutoLoad Library And Helper

  1. Go to application/config/autoload.php 
  2. set Auto load value like $autoload['libraries'] = array('database', 'session'); 
  3. set Helper value like $autoload['helper'] = array('url', 'file', 'form', 'html', 'text'); 

Comments

Popular posts from this blog

What is Codeigniter?

Welcome to Codeigniter Codeigniter is an Application development framework. Codeigniter framework is based on the Model-View-Controller development pattern. MVC is a software approach that separates application logic from presentation. Current Version Codeigniter 4 Old Version Codeigniter 3 Model Model is used to access data from the database. If we need to get data from the database so we have to create a query (logic) for the database. View The view is used to create a view of the website. We can say, design of the website. We can create view (HTML, CSS, JavaScript, Ajax etc.). Users directly interact with the view of the website. Controller A controller is responsible for controlling the way that users interact with the MVC application. A controller is used to create logic for an application.  

Stripe payment gateway integration using cUrl - Codeigniter 3

  Stripe payment gateway integration using cUrl - Codeigniter 3 Sign up for a Stripe account at https://stripe.com/ Obtain Stripe api key Setup Codeigniter 3 Project Create a library for Stripe integration Create library inside libraries folder   application => libraries => Stripe_library.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Stripe_library { protected $CI; // Default Constructor public function __construct() { $this->CI =& get_instance(); // Load necessary libraries and helpers here if needed } // Create function for checkout public function create_checkout_session($amount, $currency, $success_url, $cancel_url) { $stripe_secret_key = 'Stripe_secret_key'; $api_url = 'https://api.stripe.com/v1/checkout/sessions'; $stripeamount = $amount * 100; $data = [ 'payment_method_types' => ['card'], ...