Welcome Guest, Not a member yet? Register   Sign In
HMVC problem about "default controller"
#1

[eluser]jozeunico[/eluser]
Hello, well I want to test the extension for HMVC (clic here).

For install the extension for HMVC y copied the files "MY_Router.php","Modules.php" y "Controller" at path application/libraries.

Then I moved the welcome controller (the original from CI install) and it's view to this path structure:


application/modules/welcome/controllers/
welcome.php
application/modules/welcome/views/
welcome.php


and for testing I created this module:

application/modules/user/controllers/
users.php

application/modules/user/views/
home.php


Here is users.php code (controller):
Code:
<?php
    class Users extends Controller{
    
        function __construct(){
            parent::Controller();
        }
        
        function index(){
            $this->load->view('home');
        }
    }
    
?>

and the content at the view:
Code:
<h1>Hola mundo</h1>


The problem it's that when I go to http://localhost/hmvc/index.php the module that works it's "welcome", well that's ok I guess. When I go to http://localhost/hmvc/index.php/welcome the module works fine too.
Quote:But when I go to http://localhost/hmvc/index.php/user I get this message:

An Error Was Encountered

Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

If I go to http://localhost/hmvc/index.php/user/users then this module works fine.
How can I get both modules working without write the route till the controller's name ?
o isn't possible? it is fine my installation? or I did it wrong.?

Well Thanks for your time.
#2

[eluser]wiredesignz[/eluser]
If you want to load a default controller from a module then it must have the same name as the module directory.

ie: modules/user/controllers/user.php
#3

[eluser]jozeunico[/eluser]
[quote author="wiredesignz" date="1243486223"]If you want to load a default controller from a module then it must have the same name as the module directory.

ie: modules/user/controllers/user.php[/quote]


Yeah ! Thank you it work, that's what I needed.
#4

[eluser]costicanu[/eluser]
I use HMVC and I uploaded my site from local to online.

I have a strange error:
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

on my local server works fine! So sad! I changed only base_url and database details. I shouldn't have this error...


I fixed it! Strange thing!!! On Windows in my apps folder I don't have 'controllers' and 'models' folders. I deleted them because I have HMVC and I put everything in modules. ON Wamp works fine, but on Linux, is not! I create those 2 empty folders in my app folder from linux and now everything is fine, I think is enough to add only 'controllers' folder, but I added 'models' too, just in case...
#5

[eluser]phpwebdev[/eluser]
[quote author="costicanu" date="1302794409"]I use HMVC and I uploaded my site from local to online.

I have a strange error:
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

on my local server works fine! So sad! I changed only base_url and database details. I shouldn't have this error...


I fixed it! Strange thing!!! On Windows in my apps folder I don't have 'controllers' and 'models' folders. I deleted them because I have HMVC and I put everything in modules. ON Wamp works fine, but on Linux, is not! I create those 2 empty folders in my app folder from linux and now everything is fine, I think is enough to add only 'controllers' folder, but I added 'models' too, just in case...[/quote]

God bless u, i lost few hours to debug core source .....
#6

[eluser]Unknown[/eluser]
[quote author="costicanu" date="1302780009"]I use HMVC and I uploaded my site from local to online.

I have a strange error:
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

on my local server works fine! So sad! I changed only base_url and database details. I shouldn't have this error...


I fixed it! Strange thing!!! On Windows in my apps folder I don't have 'controllers' and 'models' folders. I deleted them because I have HMVC and I put everything in modules. ON Wamp works fine, but on Linux, is not! I create those 2 empty folders in my app folder from linux and now everything is fine, I think is enough to add only 'controllers' folder, but I added 'models' too, just in case...[/quote]

oh my god, i lost 4 hour search to find out this, thanks u so much
#7

[eluser]PhilTem[/eluser]
[quote author="costicanu" date="1302780009"]I fixed it! Strange thing!!! On Windows in my apps folder I don't have 'controllers' and 'models' folders. I deleted them because I have HMVC and I put everything in modules. ON Wamp works fine, but on Linux, is not! I create those 2 empty folders in my app folder from linux and now everything is fine, I think is enough to add only 'controllers' folder, but I added 'models' too, just in case...[/quote]

It's not such a strange thing if you look at how the filepaths to the modules' controllers is created. HMVC's MX_Router appends an ../ to the controllers folder which results in going up one folder. If you don't have the controllers folder you cannot append a ../ to the folderpath. On some OSs this results in errors on others it doesn't, but it's no false code of HMVC, it's - sorry to say - an error that you created by yourself Wink




Theme © iAndrew 2016 - Forum software by © MyBB