Step 1 – Create an admin area in CodeIgniter 3

Created at: January 22, 2015; Last update: February 2, 2017

(You may be under the wrong impression that this is the first lesson in creating a CMS using CodeIgniter 3. Actually, this continues a previous series: You can find out more about the prerequisites here:

Every respectable blog must have an admin area. In CodeIgniter there are a lot of methods to create such an area. In this tutorial we will simply make a directory named admin inside the controllers directory and also an admin directory inside the views directory.

So let’s get to work

First of all we create create the directories mentioned before.

Now we will create a controller named Dashboard (Dashboard.php)inside the application/controllers/admin directory:

As you can see, the index() method of the dashboard class will load dashboard_view which is loaded from the views/admin directory. For starters the dashboard_view.php will look like this:

After we’ve done all this, we must make sure that when someone goes to http://localhost/admin, he/she will be taken to the dashboard. To do this we simply add a route inside the routes.php file. Now, the file will look like this:

Also, one thing to note is that the Dashboard is extending Admin_Controller. In this tutorial I decided to follow Jim Parry’s example in creating more than one single MY_Controller. So, MY_Controller.php will look like this for now:

That’s it. We now have an admin area. In the next tutorial we will create the basic template for the dashboard’s pages and after that we will secure the dashboard.

31 thoughts on “Step 1 – Create an admin area in CodeIgniter 3

      1. fxf999

        it is because dashboard_view.php should be put on folder application/views/admin/dashboard_view.php instead of application/views/dashboard_view.php
        (previously i experienced the same problem Sojib because of following the view path from your tutorial, i think you need to edit it Sir Avenirer)

  1. nanart

    first: excuse my english, i ‘m french 😉
    There is something wrong, or i don’t understand:
    You write: “Now we will create a controller named Dashboard (Dashboard.php)inside the application/controllers/admin directory:”
    and i see in the script’s title: “application/controllers/Dashboard.php”…
    What is the right way, please :
    /controllers/Dashboard.php or /controllers/admin/Dashboard.php ?

    1. avenirer Post author

      Tu peux parler aussi in francais… Pardonne-moi. Tu dois creer le fichier dans “application/controllers/admin”.

      1. nanart

        It’s the same for the next pages, we should understand :
        not: application/controllers/Dashboard.php
        but—> application/controllers/admin/Dashboard.php

  2. bienchris

    j’ai suivi le tuto, c’est bien présenté. Merci.
    Mon souci c’est sur le “routes”, doit-on créer un répertoire development et un nouveau fichier routes.php dedans (application/config/developement/routes.php)? Pourquoi on n’utilise pas le routes.php dans le config.
    Je ne sais pas pourquoi aussi, car j’ai la page 404 quand je fais http://localhost/admin
    Bonne journé

    1. avenirer Post author

      Tu n’est pas oblige a faire le “routes.php” dans le config/developement. Tu peux aussi le fair dat le config. Hmmm… it’s easier in english… Can you send me your application directory in a zip file at Thank you.

  3. sounder

    Hello, I have just installed codeigniter-3.0.3 but there is not “application/config/developement/” folder. There is only “application/config/”. There I have modified routes.php as your example. But i get error “404 file not found”.

    Files are in the right folders:
    – controllers/admin/Dashboard.php
    – views/admin/dashboard_view.php

    The only difference is that my base url is “http://localhost/codeigniter-3.0.3” (I have update config.php $config[‘base_url’] = ‘http://localhost/codeigniter-3.0.3/’;)

    What’s wrong?

    thank you

    1. avenirer Post author

      Remove “-3.0.3” from the folder name… and from the config. Also, did you follow the tutorials from the previous series ( Is not really required, but you need to have a viable installation of your CI framework. At least go from episode 1 to episode 7 🙂

  4. Manveer

    For codeigniter-3.0.3 , you need to change one piece code of line in the file


    class dashboard extends Admin_Controller


    class dashboard extends CI_Controller

    1. avenirer Post author

      Woooow… Who told you that??? Don’t do that, pleaaaaaaase. Where did you get that idea from? Did you at least read the tutorials that were prerequisite for this series? Or you just want to seem professional?

  5. Andy

    Got below Error Msg

    Message: touch(): Unable to create file sessions/ci_session4dc0e26a2bb79fc8a06893ce8fbd19b9e1974a0b because No such file or directory
    Filename: drivers/Session_files_driver.php

    Did I sth wrong?

  6. Hao


    Thanks for your tutorial. I’ve followed your steps exactly, but I am stuck at displaying my admin page. When I visit http://localhost/admin, it displays the following:

    404 Not Found
    nginx/1.9.3 (Ubuntu)

    I am able to access http://localhost which displays Nginx welcome message. Could you kindly assist me on this?

  7. udarts

    Hi there,

    I am trying to follow this tutorial and use CodeIgniter 3.1.3
    But when I try the following url, I get a 404 not found error:

    When I remove the /admin I get the default welcome page so that works.

    Could you update the whole tutorial, so it works on version 3.1.3?


  8. Phil


    Et merci pour cet excellent tutorial. J’ai suivi l’installation complète de la zone sécurisée l’admin.
    Je peux maintenant administrer les groupes, utilisateurs qui sont enregistrés dans la base de données.

    J’essaye de construire un module de news avec un champ d’upload mais le user guide de CI ne travaille pas avec les render-> (et le My_Controller). Comment puis passer les variables dans les render-> ?

    Peux-tu me mettre sur la voie ? Merci.


Leave a Reply

Your email address will not be published. Required fields are marked *

No spam? * Time limit is exhausted. Please reload CAPTCHA.