Class -> File mapping – Need your feedback
We have been discussing this internally but I’d like to hear your feedback on this matter.
It is Class to File mapping and use of upper / lower cases.
Page Naming and Mapping
page_* classes are being searched in page/*. Pages are typically in low-case, although toolkit does not impose it as a limitation. Sample:
http://…/foo/bar/baz.html
api->page = ‘foo_bar_baz’;
class: page_foo_bar_baz; Sometimes extends Page_EntityEditor.php
loads: page/foo/bar/baz.php
template: page/foo/bar/baz.html (page_foo_bar_baz.html in some implementations)
PLANS: In ATK4 we expect to leave same principles for pages.
Class Naming and Mapping
$this->add(‘Foo_Bar_Baz’);
Class files are being searched in lib/, amodules3/lib and possibly some other locations. They typically come with UcFirst.
class Foo_Bar_Baz .. defined in file lib/Foo/Bar/Baz.php
Plugins / addons
In AModules3 the concept of addons is very vaguely defined. It is just another location where to look for classes.
In ATK4, we expect to have prefixes for all classes and interfaces defined inside addon. For example:
billing_SomeClass
Class naming in Agile Toolkit 4
We want to introduce the mandatory prefixing of all classes. Here are some class examples:
- api_Structured
- api_generic
- core_Controller
- controller_DB
- model_User
- billing_model_PaymentMethod
- billing_controller_Realex
- core_Form
- form_Login
- form_User_Settings
- core_AbstractObject
- core_Exception
- billing_Exception
In regards to pages:
Pages will always be loaded from page/ directory. You can add multiple directories to look into for pages with addResource()
page/ can inherit other classes, but those must be sitting inside lib/.
Bottomline: classes will always start with word in lowercase which identifies area of that class. Agile Toolkit 4 will provide api, form. Some plug-ins will bring in their own areas such as “billing”, those would have sub-areas “billing_model”, “billing_form” etc.
Second part of class will be in UcFirst and will be pretty much what we have at the moment in amodules3.
Works for me. What about you?


Sounds good, though I’d prefer to have exceptions in a separate dir. This would be logical.