Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
[hmvc] Getting 404 while trying to access module.
  • @EDIT
    Easier to read I guess: http://scrp.at/avv I've been trying to use hmvc and created simple app:
    Main controller (404 here):
    <code>try
    {
    $this->response->body = Request::factory('articles/main/content/cid/1/tid/1', false)->execute();
    }
    catch (Request404Exception $e)
    {
    echo '404';
    }</code>
    Hmvc controller in APPPATCH/modules/articles/classes/controller/main.php:
    <code>class Controller_Main extends Controller {
    public function action_content()
    {
    $this->response->body = 'ok';
    } }</code>
    What's wrong with that? Oh, I've configured hmvc in config.php:
    <code> 'module_paths' => array(
    APPPATH.'modules'.DS
    ),</code>
  • Which version of Fuel are you using? The use of the 404 exception would suggest 1.1/develop, but that doesn't use $this->response->body anymore. Controller methods are expected to return there result.
  • I'm using 1.0.1, I just followed http://fuelphp.com/docs/general/hmvc.html trying to figure it out.
    I've been trying to 'return' and 'echo' something as well but still got the same 404 error.
    HMVC controller file is being parsed because syntax errors are being handled.
  • I can not reproduce it. I've put this
    public function action_hmvc()
     {
      try
      {
        $this->response->body = Request::factory('test/admin/index/1/tid/1', false)->execute();
      }
      catch (Request404Exception $e)
      {
        echo '404';
      }
     }
    

    in the welcome controller (I already had a test module), and it works as advertised.
  • Your module main looks like its missing namespacing. It should read like this I believe. namespace Main; class Controller_Main extends \Controller
  • Thanks for your help, it was of course my fault -.- Now everything is just ok.
  • Daniel Petrie wrote on Sunday 9th of October 2011:
    Your module main looks like its missing namespacing. It should read like this I believe. namespace Main; class Controller_Main extends \Controller

    My bad... didn't see the folder structure. Set the namespace to Articles not Main.
  • I just figured it out few seconds ago, what a shame ;p
    Thanks anyway.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion