(created: November 14, 2014; last update: January 12, 2015)
OK… You are a bit knowledgeable regarding PHP, you are proficient at creating spaghetti code, and you know a thing or two about OOP. Then, someone comes to you and says something about MVC. You say “Riiiiight…”, and do your best not to betray the fact that you don’t know a darn thing about what MVC is.
So you go to Wikipedia and write “MVC” in the search form.
“Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.”
“Wow… Why didn’t I think of that?”, you say to yourselves. After a bit of reading you find out that:
A controller can send commands to the model to update the model’s state (e.g., editing a document). It can also send commands to its associated view to change the view’s presentation of the model (e.g., by scrolling through a document).
A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be “passive,” so that other components must poll the model for updates rather than being notified.
A view requests information from the model that it uses to generate an output representation to the user.
After that you can absolutely say “YES! I KNOW WHAT MVC IS!!!”. But how can you implement something like this in PHP? The easiest thing, you might say, would be to create your own MVC structure and start from there (a great tutorial about that would be PHP Academy’s). But after a lot of tries and fails you say: “F*** IT!” and look for a well established MVC framework.
If you do a Google search you will find a lot of alternatives. But I will assume that if you got to this page, you’ve found CodeIgniter to be of your liking.
So, download a fresh copy of CodeIgniter, put it inside your server’s public folder (or wherever you want it to be), and see if all went well.
Of course you can also download CI 2.2.4, but I would advise you to install version 3, even if it is in development stage.
For this tutorial we will put it inside htdocs (I will suppose that you have XAMPP installed).
Now, if you visit “http://localhost” you should see your new CodeIgniter “site”…
in
http://avenir.ro/authentication-system-with-ion-auth-and-ci3/lets-install-ion-auth-library/
not redirecting to ‘user/login’ from Auth_Controller
$this->load->library(‘ion_auth’); needs to be in MY_Controller class, not in User
No… It doesn’t. MY_Controller should be accessible by everyone, so there’s no need to load the library if we do not use it.
Hi,
I try your tutorial. But, when I access http://localhost/myapp/user/login login_view cannot display (blank).
And then, I try to change the login() content just like this
public function login() {
$this->load->helper(‘form’);
$this->render(‘user/login_view’);
}
It’s still blank.
But, if I change $this->render(‘user/login_view’) with $this->load->view(‘user/login_view’), that’s can display login_view form.
I follow tour tutorial http://avenir.ro/authentication-system-with-ion-auth-and-ci3/lets-install-ion-auth-library/
That is most likely because you didn’t follow all the steps up until that episode 🙂
I recommended you to create other tutorials like “CREATE A CMS USING CODEIGNITER 3”, maybe “BLOG”, “SOCIAL MEDIA”, or anything little complex tutorials. because you are awesome !, that’s just suggestion !.
I am from Indonesia, i very interest to learn CI. good luck..
Thank you very much Avenirer 🙂
Respect for your knowledge sharing!
Keep this blog alive, it is useful 🙂
Hello Adrian:
I hope you’re fantastic… I’ve enjoyed your tutorials, mainly the Ion Auth Config… Very very interesting the way you explain and detail the concepts behind the tool.
Another thing that I want to say, is that (I’m still laughing; in good terms friend, don’t get me wrong please) because, when I read: Codeigniter in 3 small steps, and my sorprise when I found an unfinish list !!!! 😀
Well, I’ll take your tutorials… Even, I have some questions about Codeigniter, would you offer me an online (skype) training !?
Thanks so much…
Miguel Angel Villafuerte
miguelangel_villafuerte@yahoo.com | skype: ddinsys
Well… It’s not “CodeIgniter in 3 small steps”, but “CodeIgniter 3 in small steps”. Anyway, why do you think it’s an unfinished list? Do you think there’s something missing?