Attention Expert users: What are the things you wish you knew about CI when you started?

#1
[eluser]codeamanny[/eluser]
Hi Guys,

I am about to start my first project with CI, and I want to know if there are things to watch out for or nice shortcuts that you used to get ci working nicely with your app.

Basically what do you wish you knew when you first started...

#2
[eluser]sikkle[/eluser]
i'll say better php skills Smile

see ya around

#3
[eluser]Derek Allard[/eluser]
I've written about this (or sort of about this Wink) a few times. Maybe one of these will be helpful?

Welcome to CI codeamanny!

http://www.derekallard.com/blog/post/tip...e-igniter/
http://www.derekallard.com/blog/post/hea...-me-later/
http://www.derekallard.com/blog/post/lea...deigniter/

#4
[eluser]Pascal Kriete[/eluser]
I slept on this, 'cause I couldn't think of anything yesterday. I can't today either.

I will agree with sikkle, a good grounding in the concepts helps. So if you're familiar with PHP and the MVC paradigm, you'll be in love instantly. If you don't, it'll take a good two days longer.

Other than that, I looked at a lot of code. InkType and BambooInvoice are both great examples of what's possible with CI, and they outline some good practices that the user guide just cannot teach you.

Good luck, have fun, and welcome to CI.

#5
[eluser]xwero[/eluser]
Keep it simple and flexible.

#6
[eluser]thurting[/eluser]
One suggestion I will make is to walk the framework. By that, I mean create a simple Hello World and follow the application from the bootstrap all the way through to output - constantly referencing the source files. This will give you a solid understanding of how requests are processed and of the dispatch loop and its pluggable architecture.

#7
[eluser]adamp1[/eluser]
Learn how best to make the MVC concept work for you. Yes see how others use it but find a way to like and understand.

But the big think I wish I had known before. Why did no one tell me about this before. Why did I have to wait till now to find such a great framework.

#8
[eluser]John Fuller[/eluser]
If I would have known she was going to slap me...

Er wait, what was the question again?

I can't really think of anything. Look through the ignited code section to see what has been built for CI before you try to reinvent something that has already been created.

#9
[eluser]codeamanny[/eluser]
Thanks for the advice guys... keep it coming.. this is so useful. (and the comments are entertaining too!)

#10
[eluser]gtech[/eluser]
Retrieving Models From A View

I had some issues with MVC and thought that you could not call a model method from a view (I was quite adamant this was incorrect). However MVC suggests you can as long as you do not alter the models data. An example of when this might be useful is if multiple controllers call the same view, you will not have to access the models method in every controller to retrieve the models method data.

Calling Other Model Methods Within Models

You can also call other models methods from a model. An example might be a customer model method might need to access a method from the user model. to do this you can load the user model in the customer models constructor.

Code:
class Customersdb extends Model
{
  /**
   * The Initialisation method
   */

  function Customersdb()
  {
    parent::Model();
    $this->load->model('usersdb');
  }

  function removeCustomer($id)
  {
    $query = $this->usersdb->removeCustomerUsers($id));
    ...

or use the CI instance which means you only need to load the model when the correct method is called.

Code:
class Customersdb extends Model
{
    private $CI;
    
    function Customersdb()
    {
        parent::Model();
        $this->CI =& get_instance();    
    }
    
    function removeCustomer($id)
    {
        $this->CI->load->model('usersdb');    
        $this->CI->usersdb->removeCustomerUsers($id);
        ...
    }    
}
mind you this might of been fixed in 1.6.x


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.