4

For the last couple of years, I've been developing a web application based on CodeIgniter. CI has served me well to date, but for the next generation of the software, I'm looking to move to PHP 5.3 and a more robust framework. I've watched FuelPHP since it showed up about a year ago and now that I'm getting to the point of starting the development of the next version of the application in earnest, I'm interested in giving FuelPHP a go.

My application relies on the use of multiple application directories. Essentially, there's a system application which has the system's core functionality, code that shouldn't be touched by admins because it'll be changed during updates. In addition, there's a user application directory where admins can extend and override system classes. This way, admins can customize the system without ever touching the system core (thus insulating them from losing their modifications when the system is updated). When a request comes in from the URL, I want the system to first check the user application directory. If it doesn't find the controller there, move on to the system application directory (where, in theory, it should find the file) and use that controller.

I don't want to make the mistake of approaching this problem from a CI or Kohana mindset, so what I'm wondering is what's the best way to go about doing this in FuelPHP? Since I don't have much experience with FuelPHP, I was hoping someone might be able to give me some pointers or shove me in the right direction.

Thanks!

agentphoenix
  • 67
  • 2
  • 7

1 Answers1

9

FuelPHP has an 'app' folder that you can consider the core of your application. For smaller applications, it can also contain your application code.

For larger and/or more complex applications, use modules. A module has exactly the same folder structure as 'app', but lives in it's own namespace (= the module folder name). FuelPHP supports multiple module locations, so you could have a location that contains modules you share over different websites, and modules that are specific to your website.

Without any special routing, if the first segment in the URI is a module name, controllers from that module will be loaded.

WanWizard
  • 2,574
  • 15
  • 13
  • Thanks for the quick response! I'd read about using modules like that earlier today and for controllers, it works great. However, when you get in to things like extending my core classes and replacing my core views and overriding my config files, it gets incredibly messy (as far as I can tell). Are there other ways to accomplish these kinds of things easily or am I out of luck on this one? – agentphoenix Dec 23 '11 at 20:20
  • I would add that the "app" folder is just the default application folder that comes with FuelPHP out the box. You can name that folder whatever you like, and create multiple application folders that sit side-by-side. The main "index.php" is what points to a specific application folder, so you can have multiple entry points pointing to different application folders. Each application folder can run as independent applications with their own databases, or can share resources - it is all down to the config files. – Jason Jan 28 '12 at 21:57