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

How to secure codeigniter website?

CSRF Protection (Cross-Site Request Forgery) CSRF process of an attacker tricking their victim into unknowingly submitting a request. CodeIgniter provides CSRF protection out of the box, which will get automatically triggered for every non-GET HTTP request, but also needs you to create your submit forms in a certain way. URI Security CodeIgniter contain following character in URI ·          Alpha-numeric text (Latin characters only) ·          Tilde: ~ ·          Per cent sign: % ·          Period: . ·          Colon: : ·          Underscore: _ ·          Dash: - ·          Space Password Handling ·        ...

Create rest api to send curl request from codeigniter controller to google cloud for text to speech convert using codeigniter 3.

  Create Google Cloud account https://cloud.google.com/ You can create account using existing mail id. Obtain api key for Text to Speech. Create Rest Api to convert text to speech.  We are using cUrl method to send a request. Create Api.php and extend REST_Controller  <?php defined('BASEPATH') OR exit('No direct script access allowed'); require APPPATH . '/libraries/REST_Controller.php'; class Api extends REST_Controller{ public function __construct(){ parent::__construct(); } public function index_get() { $text = "Hi, how are you doing? Very well thank you. How about you? Not so well. But thank you for asking. How is the weather there? Oh, its very warm out here."; $audioContent = $this->generateSpeech($text); $this->response(array( "status" => 1, "message" => "question 1", "data" => $audioContent ), REST_Controller::HTTP_OK); } private function generateSpeech(...

Building Dynamic Web Applications with CodeIgniter 3

Introduction:                                 CodeIgniter 3 is a powerful PHP framework that simplifies web application development. Its simplicity and flexibility make it a popular choice among developers for creating dynamic and robust web applications. In this blog post, we'll explore some essential concepts and features of CodeIgniter 3 and show you how to get started with building your web applications.  Installation and Setup:   Begin by downloading and installing CodeIgniter 3.  Configure your development environment (e.g., Apache, MySQL, PHP).  Create a new CodeIgniter project structure.  Model-View-Controller (MVC) Architecture:  Understand the MVC design pattern used in CodeIgniter.  Learn how to structure your application using models, views, and controllers.  Explore the benefits of separating application logic.  Routing and URLs:  ...