Structure
Usually, each folder in the root of the website is core (but not necessarily).
Core — is a collection of cores, templates, and virtual root folder.
The framework is the core,
your folder will also be the core (you need to create it),
each core should be stored in separate repositories.
In the simple case, you will have only two cores, for example:
It is possible to add additional cores.
All active cores need to be registered in the /config.php file (the 'cores' key).
The following folders may be located inside the core: p>
classes — contains classesunits — contains unit foldersroot — virtual server roottemplates — contains templates folders
Core
A core — is a structural entity, which is the folder with the file
File
<?php
namespace Example;
class Core extends \BlackFox\ACore {
public function GetScheme() {/* ... */}
public function Upgrade() {/* ... */}
public function Load() {/* ... */}
public function Menu() {/* ... */}
}
- GetScheme
- should return an instance of the class Scheme
- Upgrade
- been called when installing or upgrading a core, use it to synchronize the structure of tables and other amendments (see heirs for an example)
- Load
- always called if the core is active
- Menu
- called by the admin menu unit, should return an array describing the administrative menu section (see heirs for an example)
Autoload classes
By default, the core scans own subfolders of
classes — all subfolders are scanned, unlimited nestingunits — scanned into one nested subfolder
Thus, when developing your own core, place
classes in a subfolder
Own autoload classes
If desired, the described above behavior can be overridden.
To do this, override the core’s
- key — class name along with namespace
- value — absolute path to php-file
Model
A model — is a set of classes that describe the business logic of an application.
I recommend placing them in a subfolder
I recommend to use a single namespace with no nesting to make it convenient to refer to other classes.
A model class can be original or inherit any other class.
but generally the model class is a hereditary from SCRUD,
describing the structure and access to the database table.
Controllers
Controllers — are a collection of classes that
describe the order of access to the classes and methods of the model
and (optional) connects the result of their execution to a view.
A controller class can be original or inherit any other class.
but generally the model class is a hereditary from Unit
and is located in the subfolder