Love Fuel?
Donate
About
Forums
Discussions
Login
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Use module inside a package
bernhardh
January 2014
Is there a way to use a module inside a package whichs maps the url?
For example:
packages/mypackage/modules/mymodule/classes/controllers/mycontroller
should be reachable over the url /mymodule/mycontroller?
What do I have to do for that? I have added the package to allways_load already.
WanWizard
January 2014
Accepted Answer
For a module to be found, it's root folder needs to be configured in "module_paths".
You can do that in your package bootstrap. Assumping your modules are in a folder called 'modules' in your package, add this to the bootstrap:
$mp = \Config::get('module_paths', array());
$mp[] = __DIR__.DS.'modules';
\Config::set('module_paths', $mp);
Optionally followed by
\Module::load('yourpackagemodule');
if you want to autoload your module too.
bernhardh
January 2014
Thank you! For me, I had to add:
$mp[] = __DIR__.DS.'modules' . DS;
WanWizard
January 2014
Ah, yes. Sorry about that.
bernhardh
January 2014
And how does it work with Controller classes?
At the moment I have the following:
app/classes/controller/myctrl.php
class Controller_Myctrl extends \Custom\Controller_RestAuthenticated
app/classes/custom/controller/restauthenticated.php
namespace Custom;
abstract class Controller_RestAuthenticated extends Controller_Rest
And it works. But now I want to move the Controller_RestAuthenticated to the package as well.
I have added to the package bootstrap:
Autoloader::add_namespace('Mypackage', __DIR__.'/classes/');
Autoloader::add_core_namespace('Mypackage');
And moved the class to
packages/mypackage/classes/custom/controller/restauthenticated.php
But he can't find the class.
WanWizard
January 2014
Don't use
add_core_namespace(), you need the namespace to find the controllers.
WanWizard
January 2014
And what is "custom"? You can't just change the folder layout in the "classes" folder...
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,090
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
262
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
bernhardh
January 2014
WanWizard
January 2014
To Top