friendica/src/Module/README.md

31 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2019-03-03 09:05:35 -05:00
## Friendica\Module
The Module namespace contains the different modules of Friendica.
Each module is loaded through the [`App`](https://github.com/friendica/friendica/blob/develop/src/App.php).
2019-05-01 13:46:18 -04:00
There are mainly two types of modules:
- frontend modules to interact with users
- backend modules to interact with machine requests
### Frontend modules
This type of modules mainly needs a template, which are generally located at
[view/templates/](https://github.com/friendica/friendica/tree/develop/view/templates).
A frontend module should extend the [`BaseModule`](https://github.com/friendica/friendica/blob/develop/src/BaseModule.php), especially the `content()` method.
### Backend modules
2019-05-01 13:58:51 -04:00
This type of modules mainly responds either with encoded `XML` or with `JSON` output.
It isn't intended to respond with human readable text.
2019-05-01 13:46:18 -04:00
2019-05-01 13:58:51 -04:00
A frontend module should extend the [`BaseModule`](https://github.com/friendica/friendica/blob/develop/src/BaseModule.php), especially the `rawContent()` method.
### Routing
Every module needs to be accessed within a route.
2019-05-01 14:17:15 -04:00
The routes are defined inside [`Router->collectRoutes()`](https://github.com/friendica/friendica/blob/develop/src/App/Router.php).
2019-05-01 13:58:51 -04:00
Use the given routes as a pattern for further routes.
2019-05-01 14:17:15 -04:00
The routing library and further documentation can be found [here](https://github.com/nikic/FastRoute).