56 lines
2.2 KiB
Markdown
56 lines
2.2 KiB
Markdown
### xdrm-framework
|
|
|
|
#### Description
|
|
xdrm-framework is a tool that wraps my framework and all it's component's versions. It allows to build a web framework's base with chosen modules and their versions.
|
|
|
|
#### 1. Build a project
|
|
To use the xdrm-framework's project builder, just open a linux terminal and type :
|
|
|
|
1. `xdrm-framework modules` - to display the available modules
|
|
2. `xdrm-framework enable {moduleName} 1.2` - to enable a module and its version (1.2 here)
|
|
3. `xdrm-framework disable {moduleName}` - to disable a module
|
|
4. `xdrm-framework build` - will create your project in the folder `built`
|
|
5. `mv built {yourPath}/{yourProjectName}` - to move your project wherever you want
|
|
|
|
#### 2. Project's file structure
|
|
xdrm-framework is based on `all is in config` so you will have this structure :
|
|
- folder `build` which contains framework's modules.
|
|
- folder `public_html` which contains visible content.
|
|
- folder `config` which contains the modules' config files.
|
|
- file `autoloader.php` which will auto-load the components.
|
|
|
|
**Note:** In every php file you want to use framework's classes, you have to begin your file by :
|
|
```php
|
|
<?php
|
|
/* [1] dirname() as long as you're not at the project's root */
|
|
define('__ROOT__', dirname(dirname(__FILE__)));
|
|
require_once __ROOT__.'/autoloader.php';
|
|
|
|
/* [2] then you can load your classes */
|
|
use api\core\ModuleRequest;
|
|
use error\core\Error;
|
|
|
|
/* [3] and use them as long as you want without namespace */
|
|
$request = new ModuleRequest('module/method', ['id_user' => 10]);
|
|
$response = $request->dispatch();
|
|
|
|
if( $response->error === Error::Success )
|
|
echo "All is going right!\n";
|
|
```
|
|
|
|
**Note:** Some global constants are created into the autoloader:
|
|
- `__BUILD__` - The absolute `build` folder path
|
|
- `__PUBLIC__` - The absolute `public_html` folder path
|
|
- `__ROOT__` - The absolute `root` path (project root)
|
|
- `__CONFIG__` - The absolute `config` folder path
|
|
|
|
|
|
### 3. Modules
|
|
|
|
#### [3.1] api - self-managed API
|
|
#### [3.2] error - error system
|
|
#### [3.3] database - database wrapper and repository manager
|
|
#### [3.4] orm - sql orm
|
|
#### [3.5] router - apache2 router
|
|
#### [3.6] lightdb - fast key-value storage
|