Module is loaded by a main config, all working fine.
Question 1: How can I define another model within this module ? If I add file: /modules/mymodule/classes/controller/mymodule2.php
And class named after Controller_Mymodule2 (all module files are in same namespace)
Question 2: How can I make instance of model added here : /modules/mymodule/classes/model/mymodule2.php
Model class is named Model_Mymodule2
Question 3: How can I add more generic classes and static classes and how to make fuel aware of their existence it I copy them to : /modules/mymodule/classes/mymoduleclass.php
Are there Class / Filename / Path conventions I should follow ?
Question 4: Is there any bootstrap file for a module ? Fuel seems to not load any file named after that, placed inside module directory (it does for packages)?
It seems that fuel is not aware of these classes existence if they are not named exactly like module name, so that's why I'm raising this questions.
Every class in a module is in the namespace equal to that module. So Model_Mymodule2 would be accessed as \Mymodule\Model_Mymodule2. So apart from the base namespace, the file/folder structure of a module is identical to app.
Which sort of answers your question 3(b) too.
There is no bootstrap for a module. Modules are designed to modularize the app, Packages to modularize the core. It's quite easy to introduce a bootstrap for a module, by overloading the Module class, and adapt the load() method. Look in Package::load() to see how a bootstrap is loaded and parsed.
I don't understand your 3(a) question, and your final remark.
What I mean is : while creating new classes / models / controllers should I follow any naming conventions ?
Looks like when I create model file mymodule_myexample.php and define model class as Model_Myexample is all working as expected, but if I try something like mymodule_my_example and class defined as Model_My_Example fuel is not able to locate the resource...
So this leads to assumption that underscore there has some special meaning, and its not allowed to name classes with use this kind of notation. So that part of the question was about any kind of conventions we need to follow when naming /models / controllers/ classes / filenames etc.
So your example is wrong. If you have a module "mymodule", then all classes in the "classes" folder MUST be namespaced using the "Mymodule" prefix. All other naming is the same, so in case of your model, you have app/modules/mymodule/classes/model/example.php, containing
namespace Mymodule; class Model_Example extends \Orm\Model {}
so again, identical to a model in app, except for the namespace.
The underscore is a bit of legacy, allowing you to move files to subdirectories without having to namespace them. I personally namespace everything, so I don't use them.
As an example, say you have app/classes/model/this/that/other.php.
This file can contain:
class Model_This_That_Other {}
but also
namespace Model; class This_That_Other {}
or even
namespace Model\This\That; class Other {}
You could even mix and match that, but I would strongly suggest not doing that, otherwise your code will become a mess: