• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

CodeIgniter Project Startup

LPH

Flight Director
Flight Instructor
Are you ready to take your skills to the next level?

I've been slowly teaching myself PHP. Over the past few months, many people have been helping me see better ways to complete a task. It became increasingly clear last night that setting up an application is best done in a framework. Therefore, I installed CodeIgniter.

CodeIgniter is a free framework for developing PHP based applications.The framework provides the config files and libraries for SEO based paths as well as cookie sessions.

The mrforbes website has an excellent tutorial for setting up the basics. There are a few changes. First, there must be an encryption key set within the config.php file. Use a random key generator or your own. Second, setup cookie related variables so that there aren't any conflicts.

In my installation, MAMP is not installed because I chose to manually install PHP and MySQL. Also, the database hosting is not localhost but 127.0.0.1 - entering localhost in the config file will cause the app to fail to connect to the database. You can play around with vhosts or just drop the framework into a directory.

After installation, load up the directory in your browser and you should see the following welcome message. Congratulations. Now you may begin using your framework.



Best of luck and enjoy using CodeIgniter to take your skills to the next level.
 

LPH

Flight Director
Flight Instructor
Thanks for the tip.

LPH - Did you install this for a particular reason?

Yes. Research notes is presently in Caspio. Not having control over the database really bothers me. Plus, they charge a lot for data transfers. The project is better to be in MySQL, PHP, and on this server.

One more reason - less lines of code.

For example, this is the code for pulling the latest articles from Research Notes. It is far fewer lines than were used outside of the framework.

Code:
<?php
 
/* Script to pull the latest articles from Research Notes */     
 
$this->load->database();
echo "<strong>Latest Articles in Research Notes</strong><br />";
$notes = $this->db->query("
        SELECT * FROM notes
        ORDER BY `note_id` DESC
        LIMIT 5
      ");
 
foreach ($notes->result_array() as $note)
{
  echo( "<a href='" . $note['original_URL'] . "'>" . $note['title'] .  "</a> <br />");
}
?>

Also, because I was able to tie the framework to WordPress, the header and footer automatically are pulled into the application.

This is the result. It took a few hours to get this right (tied to WP, learn to call query, echo the proper results). Still. Not bad for someone just learning PHP.

Screen Shot 2013-01-21 at 5.19.26 PM.png
 
Top