CodeIgniter Forums
Unable to implement HMVC? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Unable to implement HMVC? (/showthread.php?tid=58233)



Unable to implement HMVC? - El Forum - 05-25-2013

[eluser]gRoberts[/eluser]
Hi all,

For some reason, I am experiencing issues whilst attempting to install and use Wiredesignz' HMVC plugin/library and I've tried absolutely everything with fail....

So, from the start, I copy across the MX folder into my `third_party` folder and then copy the MY_ prefixed files into my `core` folder.

At this point, I get the following error:

Code:
Fatal error: Access to undeclared static property: CI::$APP in /mnt/var/vcap.local/dea/apps/gfwv-0-9ec21c435d3b27396a7090c17847e9eb/app/application/third_party/MX/Loader.php on line 47

I then change my controller to extend the `MX_Controller` instead of the `CI_Controller` and I then get the following error:

Code:
Fatal error: Cannot redeclare class CI in /mnt/var/vcap.local/dea/apps/gfwv-0-ab605504fa4f243ea48462b4d108e0a4/app/application/third_party/MX/Base.php on line 57

At this point, I have the vanilla setup, however my controller is within the application/controllers folder.

Moving my controller to `modules/Front/Front.php` makes no difference what so ever to the above.

I only have one controller so far, `Front` being the main controller for the site.

Code:
application
- controllers
-- Front.php
- core
-- MY_loader.php
-- MY_router.php
- third_party
-- MX
--- Base.php
--- Ci.php
--- Config.php
--- Controller.php
--- Lang.php
--- Loader.php
--- Modules.php
--- Router.php

I have absolutely no idea what could be the cause. After searching about, most people are effected because the other controllers are not extending MX_Controller, however I only have one controller, which is:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Front extends MX_Controller {

public function __construct() {
  parent::__construct();
}

public function page_handler() {
  $this->load->model(array('page_model'));
  $Slug = $this->uri->uri_string();
  
  if($Slug == '') {
   $Page = $this->page_model->GetDefault();
  } else {
   $Page = $this->page_model->GetBySlug($Slug, true);
  }

  if(empty($Page)) {
   show_404();
  } else {
   $PageData = array(
    'PageTitle' => $Page->Title,
    'Keywords' => $Page->Keywords,
    'Description' => $Page->Description,
    'Created' => $Page->Created,
    'LastUpdated' => $Page->LastUpdated,
    'Slug' => $Slug,
    'IsDefault' => $Page->IsDefault,
    'PageID' => $Page->PageID
   );
   $this->load->view('templates/' . $Page->TemplatePath, $PageData);
  }
}
}

/* End of file Front.php */
/* Location: ./application/controllers/front.php */

Any idea's?

Many thanks

Gavin


Unable to implement HMVC? - El Forum - 06-07-2013

[eluser]gRoberts[/eluser]
Anyone?


Unable to implement HMVC? - El Forum - 06-12-2013

[eluser]XMadMax[/eluser]
Hey gRoberts,

I dont't see the main problem, but....

You must to rename MY_loader.php to MY_Loader.php, and MY_router.php to MY_Router.php

Any Modules directories must to be created lowercase (modules/front/front.php)

Clases must to be declared capitalized:

Code:
class Front extends    .....

I also recommend to create MY_Controller:

Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

/* load the MX_Controller class */
require APPPATH."third_party/MX/Controller.php";
class MY_Controller extends MX_controller
{
}

And any controller extending from MY_Controller

Code:
class Front extends MY_Controller

I hope this can help.

Also, you can try XHMVC: https://bitbucket.org/xperez/codeigniter-cross-modular-extensions-xhmvc , a ready-to-go HMVC with common folders to share yuor development bertweem multiple apps.