CodeIgniter From Scratch: Day 1
videos

CodeIgniter From Scratch: Day 1

This entry is part 1 of 17 in the CodeIgniter From Scratch Session
Next »

After numerous requests, today we are launching a new screencast series on Nettuts+ that will focus exclusively on the CodeIgniter PHP framework. Over the course of about 10 videos, I’ll teach you exactly how to use this framework. Ultimately, we’ll work our way up to building a custom CMS. Without further ado, here’s day one!

Day 1


Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • candlemaker

    The tutorial works fine. Just use the new CI classes as noted above and double check the code. It does work.

    • macobse

      I can’t see any video .

      • Nomi

        I was having the same issue on my system, so I asked my network administrator to allow http://blip.tv website in network firewall. Now I can see all the videos on my PC.

  • Kemal

    Hi;

    Your videos in this series is not working. Just a blank screen. Firefox, Chrome, Opera..

    Please get this fixed. I’m paying 9 bucks a month !

    Thanks !

    KP

    • Ben

      It’s working fine, if you’d read the comment just above yours it would tell you what to do to get it working, reading is a great thing.

      • mr happy

        u cant read

    • http://filmeonlinegratuite.com/ Bill

      In codeigniter 2.0.3 you have to use something like:

      class Site extends CI_Controller{

      }

      class Site_model extends CI_Model{

      }

      But still, this is a great tutorial!
      When something it doesn’t work as in the tutorial, you can find out why it’s not working on codeigniter.com.

      Tip for “complainers”: Google more. Comment less! :)

      • sumith

        Thanks for the point

      • Jason

        Saved hours of confusion. Thank you.

  • Greg

    All of these tutorials are great, however with the ongoing change in the web development and coding world, are these videos still accurately relevant to the current state of Code Igniter?

    • http://twitter.com/gabbsmo Gabriel

      Since CodeIgniter 2.0 Model, View and Controller is now named CI_Model, CI_View and CI_Controller. The author should add a notice in the blog post!

  • Alex

    Прикольные обои)

  • http://www.politissa.gr jim

    beautiful helpfull!!!

  • jack

    Videos still don’t load, just blank screen. Tried everything, every browser, even the new CI classes didn’t work. Something wrong here. Someone posted .flv file, I’ll try that.

  • http://www.360-webdesign.fr Ben

    Thanks for this great tutorial. I’m new at CodeIgniter and though the documentation is great, I couldn’t find any decent video tutorials until this one.

    However, I am having some difficulties as I am also learning POO at the same time. Primarily I am having a hard time understanding Arrays of Objects…

  • Noirita

    I cant see video – just a blank page. plz help

    • Noirita

      Its ok now. Thanks for the introductory tutorial.

  • Robo

    Great introduction to CodeIgniter. I am looking forward to watching the rest of the series.

  • moshmage

    so i had to view the tutorial twice, laad made me laught twice ^^’

  • pallav

    we have to use CI_Controller{} for the new codeigniter versions…

    can anybody tell me if that CI is the folder name in this case, or its just new syntax?

    • ormus

      No, it’s not name of folder. CI_ – new syntax

    • Miguel

      You just saved me I was wondering what I was doing wrong! Thank you!

  • andrew

    Isn’t it against the concept of the MVC pattern to have the model access the database?

    • Marta

      It is only the model that should talk to the db/ data source!

  • rohan s

    I am facing problems in running php on windows environment , can somebody help with that

    I have installed WAMP which isnt opening up.

    • Rohan P

      You must have kept IIS running…. Close the IIS from Control panel and then start the WAMP server

  • TC

    I get to 21.34 in the video where we are editing routes.php changing the default_controller from welcome to site, but when I do that and refresh the browser, I get an error:

    Parse error: syntax error, unexpected ‘{‘ in H:\…\htdocs\CI\application\models\site_model.php on line 5

    I’ve made a bunch of errors and overcome them so far, but since I followed this to the “T” and Jeffrey’s problem was only that he had “laad” instead of “load” in his code, I do not know what to do.

    I would be grateful for any suggestions

    P.S. I have appended model and controller to CI_Model and CI_Controller already, so that is not the problem.

    This is the code for site_model that has the error:
    YOUR CODE

    <?php
    class site_model extends CI_Model {
    function getAll() {
    $q = $this->db->get(‘test’);
    if($q->num->rows() > 0 {
    foreach ($q->result() as $row) {
    $data[] = $row;
    }
    return $data;
    }
    }
    }

  • timj

    You are missing a bracket to close off the if clause. Add a ) after the 0.

  • sarmen

    for anyone having trouble playing the video, i noticed it only works on firefox for some reason.
    here is the url outside of nettuts

    http://blip.tv/play/gcMVgZGVKAI.html

  • Derek

    I’m getting a “NetworkError: 500 Internal Server Error – http://localhost:8888/read/” error in my firebug console every time I try to load the model I made…it doesn’t make sense.

    • Derek

      Nevermind I got it. Put CI_Model in the model I made…would be nice to know what else is changing too I keep running into little issues.

  • pinar

    great!

  • John From Bangladesh

    Awesome…. Thank you so much. It’s really so much Helpful. God Bless….. :)

  • Emil John Bustos

    I have same problem with TC

    db->get(‘test’);
    if($q->num_rows() >0){
    foreach($q->result() as $row){
    $data[]= $row;
    }
    return $data;
    }
    }
    }
    ?>

    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\blog\thetest\application\models\site_model.php on line 5

  • Emil John Bustos

    This is the code

    db->get(‘test’);
    if($q->num_rows() >0){
    foreach($q->result() as $row){
    $data[]= $row;
    }
    return $data;
    }
    }
    }
    ?>

    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\blog\thetest\application\models\site_model.php on line 5

  • Emil John Bustos

    db->get(‘test’);
    if($q->num_rows() >0){
    foreach($q->result() as $row){
    $data[]= $row;
    }
    return $data;
    }
    }
    }
    ?>

    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\blog\thetest\application\models\site_model.php on line 5

  • Ampere

    hey that was a nice tutorial for a newbie… thanks for the tutorial

  • http://jurlan.be/cx JurLan

    This looks like a great tutorial, but before I get started: I suppose these videos are also good when using CodeIgniter 2.10?
    Thanks.

  • http://www.iwebprovider.com Innovative Web Provider

    I’ve been reviewing codeigniter since yesterday and I am just a newbie. Thanks for the post! It makes me have clearer view of the framework. I’m going to continue on watching this series.

  • Soner

    This tutorial series is spectacular!

    Thank you very much!

  • Jaiveek

    Your Videos are awesome for starter….!!! :) thanks for postin this.

  • Pieter

    Everthing works fine until I type

    Parse error: syntax error, unexpected T_ENDFOREACH in /Applications/XAMPP/xamppfiles/htdocs/ci/application/views/home.php on line 14

    <?php foreach ($records as $row); ?>
    <h1> <?php echo $row->title; ?> </h1>
    <?php endforeach; ?>

    • Kimmo

      You had:
      ($records as $row);
      Should’ve had:
      ($records as $row):

      otherwise the code seemed fine… try it again..

  • Anudeep

    Plz help me to download the video

  • thank you

    thank you

  • disafol

    Excellent intro to codeigniter, but even better intro to MVC. There are very few good videos on this. Creating classes in both M and C confused the hell out of me – which should go where – type-of-thing, but the explanation at the end cleared it up. Big hand to Jeffrey Way. Twitching to get on with it, but I’ll need to watch the rest of the videos before I dig a hole big enough to bury myself. :)

  • http://bdgeeks.com foysal

    thanks a bunch man! its really helping me out! thumbs up for you jeffery! :)

  • http://www.zziapex.com/ zziapex

    thanks for these tutorials.just finish my first video

  • http://www.entropydynamics.com Korky Kathman

    This is a pretty old tutorial, desperately in need of being updated. I’m wondering why there aren’t more tutorials for CodeIgniter out there?

  • http://www.dragoviandesign.be Peter Vermeulen

    Great tutorial ! And to counter some of the people here saying that this is outdated :), most of the system is still the same. Except for some minor things like CI_Model and CI_Controller instead of Model and Controller you won’t have any difficulty with this introductory video.

    Maybe a little hint ( since once of the main reasons to use codeigniter is to speed up development and to “beautify” your code.

    The foreach right at the end can be shortened to the following :

    title; ?>

    no need to use the foreach closing tag :) it’ll only confuse people ( unless they’re coming from a vb.net background :p )

    • http://www.dragoviandesign.be Peter Vermeulen

      and apparently i forgot to put in brackets with my code snippet

      title; ?>

  • Dave W

    How would you use get data from a relational data db? e.g. if we had a table for blog posters/user and a table for blog postings and we wanted to show all blog posts from a specific poster/user?

    could this be done via active record or would it have to be a specific model built for the one query?

  • zizidorf

    i keep geting a 404 mesage!! i cant access a welcome controller and all but if i a want access a index function in site controller i get a 404! why? if a change default route to ‘site’ it works … i am using linux with LAMP

  • Rafa S

    result() as $row) : ?>
    title; ?>
    text; ?>

    I cant get the database rows to echo out i checked my model it looks fine and the controller I have tried searching it but still new to CI but can’t get that fixed you think you can help.

  • Rafa S

    A PHP Error was encountered

    Severity: Warning

    Message: Invalid argument supplied for foreach()

    Filename: views/home.php

    Line Number: 12

    This is the warning i am getting i for got to put the right snippets to my code

  • http://tutorialoflife.blogspot.com Jiro

    Nice Tutorial for a beginner in CodeIgniter. It helps me a lot in to start with CodeIgniter.

  • http://www.lollypop.gr lollypop

    Amazing tutorial. I really thank you about this.

  • http://www.ruturaaj.com Ruturaaj

    Is there any way I can download this video? I want to have it on my Android Phone and view it as and when I get time. Somehow this page doesn’t play the video properly in Android.

  • http://namangoel.com Naman Goel

    I love the long series on CI. I’m just getting started for now..
    I’d LOOVE to see a YII tutorial. If possible.

  • http://techgangster.com Jeff

    Is anyone getting errors from home.php after following the tut? I’m not able to show the array or foreach out the data

    Site Model

    db->get(‘test’);

    if($q->num_rows() > 0) {
    foreach ($q->result() as $row)

    {
    $data[] = $row;
    }
    return $data;
    }

    }

    }

    Site

    load->model(‘site_model’);
    $data['$records'] = $this->site_model->getAll();
    $this->load->view(‘home’, $data);

    }

    }

    When input into home.php statements do not validate as well

  • http://www.gurroladesign.com george

    use CI_Controller instead of controller

  • Alex

    I can’t see anything. I’m using my iPad with latest release of the IOS. Can you fix this? Why don’t you just use YouTube for your videos?

  • Donny Agus

    cool bro.. i cant wait for 2nd lesson..
    go CodeIgniter (-_-)9

  • phpsubbarao

    where is the database file

  • Dimitrismes

    Hi I’ve just watched your video and I did exactly what you told. I created the db, keep up the steps and when at the end i tried to load the page it gives me

    A Database Error Occurred

    Unable to connect to your database server using the provided settings.

    Filename: I:\Program Files\xampp\htdocs\ci\system\database\DB_driver.php

    Line Number: 124

    I didn’t touch the file DB_driver.php

    • Pritam Roy

      open autoload.php and add $autoload['libraries'] = array(‘database’);
      This should fix it.
      Happy coding Cheers

  • Pritam Roy

    I kept getting these wierd errors that said Message: Undefined property: Site::$db

    Filename: core/Model.php

    Line Number: 51
    Until I opened autoload.php and added
    $autoload['libraries'] = array(‘database’);
    So ppl if you’re having similar problems then please do this.
    Also if you’re using the newer version of CI you’ll have to write class Site extends CI_Controller
    and likewise CI_Model