Updated api/2.2 notice and minupd for main README
This commit is contained in:
parent
7467b15664
commit
2a74ae51e7
|
@ -10,9 +10,9 @@ xdrm-framework is a tool that wraps my framework and all it's component's versio
|
|||
To use the xdrm-framework's project builder, just open a linux terminal and type :
|
||||
|
||||
1. `./xfw packages` - to display the available modules
|
||||
2. `./xfw install {packageName}:1.2` - to install a package and its version (1.2 here)
|
||||
3. `./xfw remove {packageName}` - to disable a module
|
||||
4. `./xfw build {projectRoot}` - will create your project in the folder `{projectRoot}`
|
||||
2. `./xfw install @pkg_name:1.2` - to install a package and its version (1.2 here)
|
||||
3. `./xfw remove @pkg_name` - to disable a module
|
||||
4. `./xfw build @project_root` - will create your project in the folder `@project_root`
|
||||
5. `./xfw init` - to remove all enabled modules
|
||||
|
||||
#### 2. Project's file structure
|
||||
|
|
|
@ -66,13 +66,13 @@ The API is based over a 2-level delegation structure :
|
|||
So each of your functionalities must have a `method` name and be inside a `module`.
|
||||
|
||||
<u>Example:</u>
|
||||
* module `article` contains methods:
|
||||
* `read` with argument `article_id`
|
||||
* `write` with arguments `title` and `body`
|
||||
* `edit` with arguments `article_id` and `body`
|
||||
* `delete` with argument `article_id`
|
||||
* the module `article` contains methods:
|
||||
* `read` with argument `article_id` (to identify the wanted article)
|
||||
* `write` with arguments `title` and `body` (data to write into the new created article)
|
||||
* `edit` with arguments `article_id` and `body` (to identify and replace the body)
|
||||
* `delete` with argument `article_id` (to identify which article to delete)
|
||||
|
||||
If you want to delete the article of id `52`, I must request `article/delete` passing `article_id`=`52`.
|
||||
If you want to delete the article of id `52`, you must request `article/delete` passing `article_id`=`52`.
|
||||
|
||||
2 - Usage
|
||||
----
|
||||
|
@ -160,8 +160,8 @@ In order to setup an automatic bound from HTTP requests to API directly, you mus
|
|||
```php
|
||||
// let's suppose the url is `/api/{module}/{method}`
|
||||
$url = '/api/somemodule/somemethod/1/2/';
|
||||
$url = substr($url, strlen('/api'));
|
||||
// $url = /somemodule/somemethod/1/2/
|
||||
$uri = substr($url, strlen('/api'));
|
||||
// $uri = /somemodule/somemethod/1/2/
|
||||
```
|
||||
|
||||
> ### 2) give the url to the HTTP manager
|
||||
|
@ -248,13 +248,15 @@ Then can handle various kinds of URL :
|
|||
|`{method_description}`|textual description|"Returns a specific article"|
|
||||
|`{method_perm}`|permission array|`["poster", "admin", "user"]`|
|
||||
|`{is_downloadable}`|If you want this method to return a file|`true`, `false`|
|
||||
|`{name_param}`|Your param's name|"id_article"|
|
||||
|`{name_param}`|Your param's name _*_|"id_article"|
|
||||
|`{desc_param}`|Your param's description|"Wanted article's id"|
|
||||
|`{type_param}`|Your param's type (cf. Checker)|"Wanted article's type"|
|
||||
|`{is_optional}`|Whether to make your param _required_|`true`, `false`|
|
||||
|`{name_output}`|Your output's name|"article"|
|
||||
|`{desc_output}`|Your output's description|"Article content"|
|
||||
|
||||
_*_ If you want URL (GET) parameters, the {param_name} must be `URL_0`, `URL_1` and so on according to the index wanted in the URL.
|
||||
> `api/module/method/URL_0/URL_1/URL_2/`
|
||||
|
||||
4 - implementation
|
||||
----
|
||||
|
@ -284,10 +286,11 @@ Arguments are passed to the method as a single argument which an associative arr
|
|||
_Notes_:
|
||||
* Optional parameters if not given are set to `null`
|
||||
* parameters of type `FILE` are given by reference but the use is the same as normal parameters
|
||||
* URL parameters are called `URL_0`, `URL_1` and so on according to their order.
|
||||
|
||||
### Ouput required
|
||||
|
||||
You must return an associative array containing at least the field `error` containing an instance of `/api/core/Error`, then you can add useful return.
|
||||
You must return an associative array containing at least the field `error` containing an instance of `/api/core/Error`, then you can add whatever you want to return in the array.
|
||||
|
||||
If you don't return the 'error' field, by default it is set to `new Error(Err::Success)`.
|
||||
|
||||
|
@ -327,3 +330,10 @@ To add a new type, just open the file `/build/api/Checker.php` and add an entry
|
|||
|
||||
> **Note:** It is possible to chain `array` type as many as needed.
|
||||
**Ex.:** `array<array<id>>` - Will match array only containing arrays that only contains `id` entries.
|
||||
|
||||
|
||||
## (5) Advanced
|
||||
|
||||
### Before and After scripts
|
||||
|
||||
Each time a **method** is called, the api **creates an instance** from the class, and after the execution, the class is **destroyed**. So you can implement the methods `__construct` and `__destruct` to add before and after scripts.
|
Loading…
Reference in New Issue