Welcome Guest, Not a member yet? Register   Sign In
How to develop / package a component for resuse and sharing ?
#1

[eluser]Erikk[/eluser]
Hello,

I am new to CodeIgniter and trying to understand what are the recommended coding practises in CodeIgniter.

There is something that I can't grasp is why the controlers, views and libraries are separated into different directories. Does it not complicate how to package a ready-to-use component that you want to share with your friends ?

For example, if I write a "component" to handle user login, that would contain the following :
- a view to display a small login form
- a controller to handle the submitted user and password and preferred language
- a library to handle checking user and password in the database and loading the correct language files.
Furthermore, the component must be able to handle several languages to display the correct text on the login form.

Let's suppose that I name my component "login", which will be packaged into a login.zip file with the following structure :
- application/system/config/login.php
- application/system/controlers/login.php
- application/system/language/english/login_lang.php
- application/system/libraries/login.php
- application/system/views/login.php

If I give this to a friend who wants to use it, I was thinking : easy he just has to unzip the login.zip file into his codeigniter directory.
Now what if he already has something called login.php in one of the directory or on some of them ?
Would he then have to manually create in each directory (config, controlers, views, language, ...) a sub-directory with a unique name that is not present in any of the other directories under application/system, and then manullay copy the files in the corresponding newly created directories ?
Furthermore, how will the "login.php" view know the path to the "login.php" controller ?
The calling controler would have to indicate via a parameter to the login view there the login controller is ?

That does not seem very friendly and intuitive ...

Would someone help me see clearer ?
Thanks ahead.
#2

[eluser]Sam Dark[/eluser]
Read about matchbox.




Theme © iAndrew 2016 - Forum software by © MyBB