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
  • http://vivalacollege.com Kevin Urrutia

    Great tutorial

    • http://www.jeff-way.com Jeffrey Way
      Author

      Really Kevin? After five seconds of being posted?

      • http://evanriley.xiaimix.com Evan Riley

        He’s scrubbed the video really fast, and learned EVERYTHING ;o

        Great tutorial Jeff.

      • http://www.brenelz.com/blog Brenelz

        People just love posting first in hopes that people will visit their website…

        Annoying!

      • http://www.eirestudio.net Keith

        Heh heh :)

      • http://www.noobcube.com Jarod Taylor

        I think Envato should implement a reverse hierarchy on their commenting system, putting the most recent comment first. This would probably eliminate the arbitrary “first!” comments.

      • http://www.demogeek.com DemoGeek

        It’s really annoying to see people trying to game the commenting system to their advantage. Actually it might backfire if you leave those silly comments. You might get a click but people might not want to visit your site by remembering and typing in the URL.

        Commenting system brings in additional perspectives, thoughts and even points out any flaws with the article. But because of exploitation, to get those useful comments we have to skim thru so much of static one-liners and that’s terribly annoying.

        Jeff – I’m sure you have comment moderation…I’m wondering why you are approving these one-liners!

    • http://eneza.wordpress.com Eneza

      AHIHIHHI! EVAN RILEY Nice Observation!

    • http://www.twitter.com/kevinquillen Kevin Quillen

      It’s just spam to me when posters have nothing to offer more than ‘great tut’. Did you take anything away from it? Have any ideas from CodeIgniter because of it?

      • http://omarabid.com Omar abid

        Yes comments are made for critic and to correct something/discuss it in the post, not to say “great tut”.

        A good solution is to create a user page, links will be made to that page, it’ll reduce spam.

      • http://benbankson.com Ben

        I disagree. While comments are definitely a great way to have a discussion and learn from (I certainly have learned many things from them), they are also a way to simply let the author know you appreciate their work.

        Great tut by the way ;) I’ve been trying to decide which framework to learn and this is really exciting for me!

        Thanks Jeffrey!

  • http://tuntis.net tuntis

    I wish the video framerate would be higher – it’s quite choppy right now.

    • http://www.jeff-way.com Jeffrey Way
      Author

      Might be better to let it buffer a bit. You can also download a high quality version from iTunes. Just search for “Nettuts”.

      • Jesse

        Jeff, how long before it shows up in iTunes? I’m not seeing it there yet.

      • Jerichvc

        Thanks Jeff, I didnt know its available in there.

      • http://omarabid.com Omar abid

        the video player is completely “SH*T”, can’t you change it with JW FLV?

      • http://blog.jackbliss.co.uk Jackbliss

        Quotation marks for emphasis? For shame… Now it looks like you were being cynical. Besides, this flash player is one of the best out there – the JW player is really quite ugly. Having a specific flash player that’s only for nettuts is great for brand identity.

    • http://www.jeff-way.com Jeffrey Way
      Author

      Hmm..Should be soon. All of the files are there. Just waiting for iTunes to update. :)

  • Kyle

    Nice job!

  • http://pixelcraftwebdesign.com/ KevinBrown

    This is great!

    Tutorials like these keep my hope alive for good content.

  • http://alexwind.com Alex Wind

    :-O You finally got a mac!!!!

    • http://www.jeff-way.com Jeffrey Way
      Author

      I’ve had a Mac for a very long time. :)

      • Nouman Saleem

        Lucky one ;]

      • http://shumdesign.wordpress.com ebflute

        Which model Mac do you have and are you running any VMWARE?

  • Joakim

    Wow, just watched it. Really cool. I think you just made me understand the ground principles of MVC. I don’t know why, but I think it helps so much when I learn things from screencasts rather than reading about it. I will follow this serie the upcoming weeks/months.

    Really interested to see how the admin panel is managed with the MVC and CI. Can’t wait untill the next screencast.

  • http://www.surefirewebservices.com Jon

    It’s a long one! I’ll get to it later tonight. Perfect timing though for the Code Igniter Tuts, thanks!!

  • http://www.khalidsharif.com Khalid Sharif

    How i can download it from iTunes?

    i searched in the iTunes store i didnt find anything =S

    • http://eyoosuf.blogspot.com/ Yoosuf

      use ITUNES :P

  • http://www.mment.at mment

    Great tutorial Jeff!

    Couldn’t you write short PHP in CI?? I mean instead of ???? Or do I mix something?

    Can’t wait for the next one!

    • http://www.mment.at mment

      Oh!

      I mean instead of

      • http://www.mment.at mment

        Can’t write PHP in comments! So you could delete my comments ;)

    • http://www.jeff-way.com Jeffrey Way
      Author

      Sure – you can use short tags if you like.

  • Piero

    Great, i love CI :D

  • http://www.davepoon.net Dave Poon

    I love it! I have used Codeigniter for a while, but just love to see how people use it and teach it!

  • Johan

    I really like that you do this series. But I wish that when showing the basics of CI you show talk about constructors. Also I don’t think the way you retrieve records in the model is very handy. I would return like this in the model:

    $this->db->select(‘*’);
    $this->db->from(‘tablename’);
    return $this->db->get()->result_array();

    And in the controller:

    $data = array(
    ‘records’ => $this->site_model->get_all()
    );

    $this->load->view(‘home’, $data);

    And in the view:

    And check out the userguide. There are some coding-guidelines which will help your code look good (as you probably end up with libraries, helpers and stuff contributed by other communitymembers).

    Great initiative though! The CI-framework is really cool and very well fit together. It really makes development smooth and easy extendable.

    Take care!
    Johan

    • http://www.jeff-way.com Jeffrey Way
      Author

      Johan – We’ll go over all of that in coming weeks.

      • Johan

        Okidoki! :)

  • http://webmaestria.blogger.com Gerardo Jaramillo

    I love codeigniter… much easier than symphony and CakePhp.!!!

    • http://www.eatupdrinkup.com Dave

      Can you tell me how explain how it is easier? I am a non programmer and my site http://www.discoverchefs.com was coded in cakephp by my partner.

      I always like to try an understand the different frameworks that are used.

      Eatup Drinkup,
      Dave

  • http://bwebi.com barat

    Why CI … no PHP5 and no Full OOP … Kohana is fresher version of CI … but from other hand the logic from CI can be used in Kohana then maybe this viedo series will be usefull after all :)

    • http://www.jeff-way.com Jeffrey Way
      Author

      CI supports PHP5.

    • Johan

      As Jeffrey said, CI supports PHP5. Kohana has some great features but the community is not like CI’s, ie very friendly and active.

      Also, full OOP has it’s advantages but tends to raise the learningcurve. I think CI is great for most projects… Afterall, it comes down to your personal taste… :)

      • Felix Boyeaux

        Sure, CI supports PHP 5 since PHP is backward compatible, but the fact that CI also supports PHP 4 tends to make the framework slightly less powerful than if it was using strict PHP 5.

        I’m thinking of the lack autoloading features, visibility protection for instance. Those exists in Kohana but not in CI.

      • http://www.kevtrout.com kevtrout

        Felix, autoloading is supported in CI.

      • http://sigswitch.com Matt

        @kevtrout, no not in the conventional sense it doesn’t

        What Codeigniter does is let you specify certain files which should be loaded on every page view, whereas a good PHP5 framework will use php’s autoloading capabilities to load the class when you initiate an instance of it.

        See: http://us3.php.net/manual/en/language.oop5.autoload.php

  • Myke

    Great Tut!

  • Michael Tysk-Andersen

    Hi Jeffrey.

    Really enjoy your screencasts, but when you toggle between two applications then please use command-tab instead of exposé. Its highly confusing to watch exposé in a screencast!

    • sina

      +1

  • Felix Boyeaux

    Haven’t watched it yet but i’ll be sure to do so as soon as possible! I’ll definitely be following this.

    I must admit I prefer Kohana however… IMHO Kohana is somewhat of a CI, but better. Why? Well simply because Kohana is strict PHP5 OOP, and thus Helpers, Models, and Views are autoloaded, the global namespace is kept clean because helpers are a standalone class, and much, much more.

    Still great to talk about CI since it’s probably one of the best frameworks out there.

  • http://www.bluebit.co.uk Mark Jones

    I’m currently trying to choose a PHP Framework to learn and these tutorials on net tuts are making me want to use CI, I’m just concerned about learning something that it seems like people are going to be moving away from in favour of, as people are pointing out, Frameworks that make no compromises and just drop PHP4 for Strict PHP5 OOP. However at the same time, I think these tutorials may be a good introduction to MVC & developing with a framework and no doubt a lot of the knowledge can be applied when working with Kohana specifically considering it is a branch of CI.

    Just don’t want to limit my options.

    • Felix Boyeaux

      As you say, Kohana is kind of a fork of CI – even though the code has been totally rewritten and improved – and you should therefore have no problem whatsoever migrating from CI to Kohana later on if you feel the need to do so

  • http://www.gbedufiva.com Gbolahan

    JW can u be my MASTER and i’m ur student like dey do in d movies..learnt alot from u..(waiting 4 ur reply)

  • Ernest Mountain

    Any chances of doing the same but with CakePHP?? I wanted to learn a PHP frameweork but I didn’t know which one was better, so i my “research” I found that John Snook said that CakePHP is way better.

    Thanks in advance

    • http://www.jeff-way.com Jeffrey Way
      Author

      Actually – as I remember it, Snook noted that both frameworks are really good. However, he tends to prefer CakePHP a bit more. Others feel differently.

      • http://mentomedia.no Christian

        Who the heck is John Snook?

      • http://www.collinbrady.com Collin

        Someone important in the industry – http://snook.ca/

    • http://designblurb.com Sumesh

      (in reply to Christian) You must be kidding me, or living under a rock, haven’t you come across a reference of Snook? Here’s his homepage anyway (snook.ca), in one line I’d call him excellent and thinking-on-his-feet coder, good designer (rare among programmers), and CSS expert.

  • http://www.seo-geek.de Daniel

    What a cool series! Great Tutorial Jeff. Keep on the great work! I tried to find some german tutorials – no way. Got to make my own by the moment i can program in ci :)
    This one is really easy to understand. All thumbs up!

  • http://www.mortfiles.se Jimi Wikman

    A very nice tutorial!
    I’ll look forward to follow this in the weeks to come :)

  • http://www.twitter.com/chriscandy Christer

    Finally a screencast series aboot CI. Been waiting for this some time now. Now it would be perfect if Expression Engine 2.0 would be released when this series is completed.

  • sven

    nice one, enjoyed it very much.

    jeff, get something like quicksilver and give your dock a break ;)

    • Jeff Way

      I use quicksilver. The dock just looks cluttered because I had to record at a low resolution.

  • http://www.prop-14.com Randy

    Well, I have read the CI manuals a tiny bit confused, and once again, you come to the rescue to explain it so well as you did with the WordPress+ series!

    Nice work! Feel free to post the rest of the series tomorrow(JK!)

  • Wade

    Thanks Jeff, been waiting for someone to do something on Code Igniter I have wanted to try it out for a while now.

    A quick question (i think) though, towards the end of the screencast you loaded all the data into $data['records'] (via the controller) but then in the view you called the data back by referencing $records how does that work? sorry very new to OOP.

    • Ian

      The way CI works when you pass the data array to to a view it automatically converts all the array keys to variables.

      • Wade

        Awesome thanks, i watched the tutorial over and went onto the codeigniter site and did some reading… thanks for the help though.

  • Gene

    thanks for this great screencast.. will probably watch this by weekend.. cheers!

  • Chris Brown

    Awesome! I’ve been wanting to get my hands around CodeIgniter for a while and this will definitely will be helpful.

    I assume a lot of these tutorials can be ported to Kohana since it was built based on the CodeIgniter framework, correct?

  • http://www.webeventures.com Prabhjeet

    Now that’s gonna to be interested series. I love it. Keep it up. Thanks.

  • Steve

    Good stuff. I’ve worked in some J2EE frameworks and the hardest part is always figuring out how all the parts are wired together. CodeIgniter looks like a big improvement over the embedded PHP 3 stuff I wrote back in the day. But the object model and MVC pattern do add complexity and indirection. So far, so good.

    • http://eyoosuf.blogspot.com/ Yoosuf

      you can t compare PHO with JAVA, JAVA is a Mess :P

  • http://tuvidaloca.net Rata

    The tuts in general are great, but I would prefer an iTunes version, if posible for direct download.
    With my bandwidth here in Spain it’s a pain to se this video in a decent resolution.

    Kind regards
    Rata

    • http://net.tutsplus.com Jeffrey Way

      There is an iTunes version. :) Just search for Nettuts.

  • viaria

    what is ganna look like or work like in the end of this course,
    that is what i wondering,

  • james

    thanks guys! a more robust PHP/MySQL from scratch would be helpful too. Been through the Lynda stuff, but some better real world applications would be awesome.

  • http://www.brianswebdesign.com Brian Temecula

    I sure wish I could have seen this tutorial back when I was trying to wrap my brain around MVC. This is an excellent tutorial, not just for CI, but for MVC in general.

    My site is currently powered by CI. I don’t see any reason to change. CI offers everything I need in a framework, and for those who think CI needs to drop php4 support, who cares? Benchmark it and see that CI rocks!

    • Felix Boyeaux

      Benchmarking is not the only thing to judge a framework… Sure CI is fast. Lightning fast. But the fact that it doesn’t take advantage of PHP 5 makes coding more painful since the latest features aren’t supported.

      So actually, i DO care that CI doesn’t drop PHP 4 support.

  • http://eyoosuf.blogspot.com/ Yoosuf

    good idea, recently i found KOHANA is better one than Codeigniter, any way both are similar, keep-it up Jeff

    i have some questions, still i didn’t get from the Codeigniter forum to, hope you guys can help me on this

    if you guys wanna know a bit about KOHANA visit for http://eyoosuf.blogspot.com/2009/07/kohana-yet-another-php-framework.html

  • Drazen Mokic

    Hey i love CI, nice series.

    Can you share you Desktop Wallpaper Jeff? =)

  • Anthony

    Great tutorial. This really helped me understand MVC Design, mainly because you took the time to cover the model. The other screencasts I’ve seen are just “Here’s the controller, here’s the view. That’s all you need to know!”
    Thanks for explaining what the model is and how to use it!

  • http://eneza.wordpress.com Eneza

    RAHAHAHAHAHA!!! Mr. Jeffrey Way! Nice Comment! WAHAHAHAHA

  • http://nathanledet.com Nathan Ledet

    Nice tutorial.

    Really looking forward to seeing some AJAX and jQuery goodies…

    Also, Jeff, I see a lot of CodeIgniter apps that use Modules. some use a plugin called Matchbox – Can you go over the concept of “modules” and why they are important and why they should or should not be used? That would be very helpful!

    • http://net.tutsplus.com Jeffrey Way

      Sure – but that’ll be several videos down the road.

  • dronix

    very nice. I’m looking forward to the series. I don’t know how you’ll be breaking up the tut but it’ll be nice if you get to explain the design and coding process of the cms. This of course would be a separate tutorial in itself.

  • http://www.imblog.info Muhammad Adnan

    good tut jeff ..
    great site , i visit it daily !

  • Joel

    Have you used Joomla! ??
    If so, do you know how it compares?

    I am a heavy user of Joomla! and i love it, but havent used CodeIgniter and dont know the difference?

    • http://eyoosuf.blogspot.com/ Yoosuf

      that sounds cool, could you make a Tutorial How to make as Joomla Templates

    • Johan

      CodeIgniter = PHP Framework
      Joomla = Content Management System (CMS)

    • chris

      This question make my hairs going down of my head… but ok .
      Joomla is a CMS, all is already done for end user … you just have to modify it as you like to fit your goal by adding module, component and templates but you cannot developp everything you want with it.

      CodeIgniter is a FRAMEWORK , that’s mean with CI you can build a Joomla CMS like (with a lot of time and skills), and create everything you need or imagine.

      FRAMEWORK is a tool to developp faster what you have in mind.
      CMS, all is done, just use it.

  • http://www.designstudio16.com saurabh shah

    m working on Code Igniter since a year now .. and its amazing … m loving it :)
    All the best for the video series … Hope it will be gr8 … thnx for sharing it …

  • http://shumdesign.wordpress.com ebflute

    Jeffrey, this is a great tutorial! You are explaining the MVC model very well. I noticed on some of the pages you do not use a closing php tag, is there a reason for that?

  • Ian

    One suggestion I’d make for the file structure is moving the application and system folder from the document root. That way when you put your site onto a production server there is no way people can get to those directories.

  • Guario Rodriguez

    Great Tutorial! I’m excited to learn about PHP and Code Igniter. I have a couple of questions.
    1. I saw you have both Coda and TextMate, which one would you recommend if you had to choose one? I’ve tried Aptana Studio and it is fine but I think I want a more light weight IDE.

    2. What is the syntax coloring scheme you are using in TextMate, I like it.

    • http://nathanledet.com Nathan Ledet

      I use Coda and TextMate. Both have perks that I like

  • pab

    Nice one Jeff, I love CodeIgniter

  • tom

    free it ebooks
    php, css, jQuery, JavaScript, c#, c++ and more

    http://www.itebooksforfree. blogspot.com

  • http://www.bittrack.it/ Raspo

    I really like these “from scratch tutorial”…
    ..i’m waitin for the next episode!

  • http://mohamedaslam.com Mohamed Aslam

    Waiting for such tutorial way way back.

    Thank you Jeff for the grate tutorial