I have created am Admin dashboard in the app folder that is using Ormauth with models users permissions roles etc; it is running fine in the app. I have search all over and most FuelPHP module example links are DEAD! Doe's some one have a nice tutorial of how to move this into a module?
Even the FuelPHP doc's do not give a clear example of creating a module. A good example of a module like Admin Dashboard with Ormauth would be an asset to the FuelPHP documentation.
You want to move the entire app folder, or just parts of it?
A module has exactly the same structure as the app folder, they only difference is the namespace.
So it also contains classes, views, etc If you move a controller, all you have to do is: - add the namespace if the controller didn't have one - or prefix an existing namespace with the module name
And you need to check the code for all references to Fuel classes that are are not prefixed to global (i.e. don't have a leading backslash). You need to add that leading backslash.
so
class Controller_Test extends Controller { public function action_index() { return View::forge('test/index'); } }
becomes
namespace Modulename;
class Controller_Test extends \Controller { public function action_index() { return \View::forge('test/index'); } }
Obviously, when you move the code into a module, by default the URI changes, so that means you'll have to look at redirects too.
It's difficult to see from there where it goes wrong, but the Request class logs every request in development mode, so check your logs what is requested, and where it redirects to.
Now that I can see your file structure, I see that you have all code in an admin folder. This makes moving it a bit easier:
class Controller_Admin_Fresh extends Controller {}
becomes
namespace Admin; class Controller_Fresh extends \Controller {}
by moving app/classes/controller/admin to app/modules/admin/classes/controller.
In this case the URI will remain '/admin/fresh/index', and you should not have any (or at least a lot less) redirect issues.
Line 97 is primarily there to avoid loops. Since you have moved the controller to a namespace, check if \Request::active()->controller still contains "Controller_Admin", and not "Admin\Controller_Admin" which makes the if fail...
Module route are required to have the primary segment as the module name. Meaning all your module routes should start with 'admin/...' otherwise they can not be used.
So you can use module routes to route from the module to elsewhere, you can not use module routes to route from elsewhere (simply because the routes are only loaded when it's already determined it's a module request).
In general, I try to avoid routes, and try to design my controller is a structured and logical way. Since most of the URI's are never typed in by users, it doesn't really matter what they are. Only URI's used as application "entry" may benefit from shorter URI. It is also a lot more flexible towards development, not having tons of hardcoded routes...