Autoloading Behavior
The framework uses a custom autoloading scheme.
In this scheme, class files must match their class names and .php extension, and namespaces must correspond to directory structure under the src/Libraries/ or src/Controllers folder.
Specifically:
- Controllers: Any controller class is placed in
src/Controllers/and is routed automatically. fxsrc/Controllers/AuthController.phpwill be routed from URI/auth - Other Classes (Libraries): All other classes (services, models, utilities, etc.) are placed under
src/Libraries/
The namespace (if used) must mirror subfolders of src/Libraries. For example,src/Libraries/User.phpdefines a User class, andsrc/Libraries/Store/Product.phpdefines classStore\Product, matching theStore/subdirectory. - Composer Autoloader: If the project includes a
vendor/directory, either at the top-level or insidesrc/, the framework will register Composer’s autoloader automatically.
<?php
// File: src/Controllers/AuthController.php
class AuthController {
public function index(): void {
// ...
}
}Other classes are autoloaded from the src/Libraries directory.
<?php
// File: src/Libraries/User.php
class User {
public function authorize(): bool {
// ...
}
}The composer generated autoloader will be registered, when the vendor directory is present in either document root, or its parent.