This tutorial will be the first of a five part series where we will built a social network site similar to Twitter from scratch. We will be using the CodeIgniter framework for the core of the website and jQuery for the effects. In this first part we will be configuring CodeIgniter to display everything correctly and we will also set up a database and connect to it.
Download and configure
Download the CodeIgniter framework from their website. We don't need to download anything for jQuery because we will be loading it directly from Google as it's quicker to load.
Once you have downloaded the latest version of CodeIgniter from their website, unzip it and copy the files to your public_html folder or equivalent. Rename the CodeIgniter folder to ci_twitter.
Now if you go to http://localhost/ci_twitter you should see something similar to the image below.
We now need configure a database to connect to CodeIgniter so that we can use it to insert and retrieve information. Go to phpMyAdmin or whatever you use for MySQL databases. Create a database called ci_twitter.
CREATE DATABASE `ci_twitter` ;
For now we are only going to create a table for the users, in another part we will create other tables when we need them.
CREATE TABLE `ci_twitter`.`users` ( `user_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `user_fullname` VARCHAR( 50 ) NOT NULL , `user_username` VARCHAR( 50 ) NOT NULL , `user_email` VARCHAR( 50 ) NOT NULL , `user_password` VARCHAR( 50 ) NOT NULL , `user_protected_updates` TINYINT NOT NULL DEFAULT '0', `user_location` VARCHAR( 50 ) NOT NULL , `user_web` VARCHAR( 50 ) NOT NULL , `user_bio` VARCHAR( 160 ) NOT NULL ) ENGINE = MYISAM
Now that we have set up our database and have inserted a table we will configure CodeIgniter to connect to it.
Navigate to database.php by going to ci_twitter -> system -> application -> config -> database.php. From here enter the correct information for your database so that it connects.
We need to auto load the database library because we will be using it a lot.
Go to autoload.php in the same folder as database.php.
$autoload['libraries'] = array();
$autoload['libraries'] = array('database');
The database library will now load every time without us having to put $this->load->library('database'); in every controller.
End of Part 1
This is the end of the first part of approximately five parts.
Part 2 will be following tomorrow. In part 2 we will be creating a sign up so that we can add users to the database.
You can download part one from here
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.