How to use HMVC for Codeigniter 2.1.* when index.php is moved?

420 Views Asked by At

I am trying to build a CodeIgniter application with my index.php inside a "public" folder /Applications/MAMP/htdocs/public/ in the website root. I have setup my vhosts etc to point to this index.php file. I wanted to go for a module based approach and so ended up using Modular Extensions - HMVC . I placed the core files and the third party files in the corresponding folders, and created a modules folder in the application folder. I then proceeded to create a "login" module inside the modules folder alongwith the required "controllers/login.php" , "models" and "views"

class Login extends MX_Controller{
    public function index()
    {
        log_message('error','reached module');
    }
}

Now when i try to load http://localhost/login , I get an error log in apache_error.log saying

File does not exist: /Applications/MAMP/htdocs/public/login

http://localhost works fine displaying the welcome screen of CodeIgniter gniter

This is the path structure :

application/modules
└── login
    ├── config
    │   └── routes.php
    ├── controllers
    │   └── login.php
    └── views
        └── login.view.php

Content of modules/login/config/routes.php

<?php
$route['login'] = 'login';

httpd-vhosts config :

<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs/public"
    SetEnv APP_ENV development

    <Directory "/Applications/MAMP/htdocs/public">
        Options Indexes FollowSymLinks Includes execCGI
        AllowOverride All
        Order Allow,Deny
        Allow From All
    </Directory>
</VirtualHost>
1

There are 1 best solutions below

0
On

I finally managed to get my code working. Wrote a small tutorial around it on setting up. You can refer it here