Welcome Guest, Not a member yet? Register   Sign In
Starting with CodeIgniter setup: suggestions & best practices

[eluser]Watermark Studios[/eluser]
Great learning path...and so true...RT(F)M!

That's a really good POST! Damn I LOVE IT!

Great Job Buddy!

Thanks a lot

My personal best practices (you can take em or leave em =P):
_Write everything in camelCase when possible
_Always set up a main controller in the libraries directory, from which all your other controllers extends.
_Everything that can be output, make it a view. Eg: error messages.
_JS files in /js. Call them through a view.
_Always follow the same naming pattern, like getComments, getSomething. Wrong: findComments, fetchSomething, giveMeTheStuff.
_I can say the same about database tables and columns. If the primary key is the table's id, name it just id. If it has-a-thing, make a column named thingId, or thing_id. But stick to the one you choose.
_Try to make your methods for general purpose reusable when possible.
_Never hardcode. Make a custom config file and use it (it's clear in the userguide)
_Avoid using include/require. Only use it to add functionality to your codeigniter, but do it inside a library.

If something else comes to my mind ill write it later

Thanks for this post. Very straight forward.

Useful post I like this. thanks

Nice post.. Thanks Smile

I know that those are your PERSONAL best practises but using camelCase is against the official CI style guide which prefers multiple words separated by underscore. Its a matter of taste really, but IMO separation with underscore is more clear to me. Everything else looks good to me so thats the only one Wink

The style guide is very good and I'll try to stick with it in all my PHP coding, not just CI. I think it has made my code more readable by others.

Oh yeah and Jelmer, good job! Smile

Thanks for all the compliments.

I changed the bit about Auth libraries a bit last week as the link it refers to has gotten a bit old.

I'll add something about ORM's this weekend as that's something people ask about often as well.

While I would agree with many of your points, I tried to write this without anything (or at least very little) that could be considered a personal opinion rather than a best practice.
That being said, I might put something in there on your points of making things as general use as possible (DRY), on using consistant naming (although I won't put a preference on either camilcase or underscores) and on using the language and config libraries.

[quote author="Jamie Rumbelow" date="1263669444"]This is really helpful - thanks for posting it! I'm making it sticky so more people will hopefully read it Smile[/quote]

It's an interesting read, verily, but sticky threads really annoy the living cranola out of me - they are a bad answer to a problem that has a better solution.

Plus they tend to end up being full of pointless and irrelevant messages. Viz $this.

If there wasn't a wiki available for long-term storage of knowledge, sticky threads might make a bit more sense. But if every useful thread were to be stickied, you'd end up with several dozen pages in each forum's thread-list before you got to a thread with any kind of currency. Plus people seem to be unwilling to search using a button labelled 'search', or look in the FAQ / wiki - so it's a tough sell suggesting that people will read through sticky threads before posting.

Just my 2c worth.

Lists like this are extremely valuable. If they didn't exist it would take a lot longer to acquire the info from random forum posts, stumbling around on Wikipedia, etc. As someone who discovered all of the information by stumbling randomly around online, I am grateful to see lists like this posted. Great starting point & awesome info!


Theme © iAndrew 2016 - Forum software by © MyBB