Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Tutorial
#1

[eluser]Unknown[/eluser]
I've only ever coded procedurally, all self taught. Recently I've caught wind of the wonderful world of frameworks so thought I'd begin trying to get my head around OOP and CodeIgniter seemed like a great place to start as you're sort of forced to code "correctly".

Anyway enough of the boring story!

I set out to go through the User Guide and tutorials to put me on the right path, but hit a bit of a stumbling block. I thought I'd just detail it here to contribute to the community, even if only in a small way.

If I come across anything else on the way I'll update this post.

1.
It's recommended that the application and system folders are placed above the root directory for security. I feel that people would benefit from an update to the part on creating the first controller, reiterating the fact that if you have installed it in this way then the following code will be incorrect.

Code:
public function view($page = 'home')
{  
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{

Although it's fairly simple, it took me a while to realise what the issue was. I was in the mindset of "I'm instantiating the files different to how i normally would (linking to them directly) so therefore they would be relative to what I'd set in the index.php file". Obviously that's wrong as the file_exist function is executed straight away, the path isn't parsed to include what had been set in the index.php file.

To add to my knowledge I'd like to know the following.

a) Do you use the file_exists function every time you work with a new file, or is it really just over the top error checking?

b) How do you reference these files?

The tutorial recommends using the full server path but this can be very long to keep writing out and if you're testing the application locally as well as having it live externally then this will not be the same path. On the other hand one could use "../application" for example, but that wasn't a "recommendation".


Thanks for helping out a newbie Wink





Theme © iAndrew 2016 - Forum software by © MyBB