**This is an old revision of the document!**
DoliMobile - Back (PHP)
The dolimobile back office must be integrated into a normal dolibarr module.
So when you deploy dolimobile in your dolibarr module you will have a few new folders that will appear:
mobile
: the folder that will contain all the source code for the mobile part (front end in React, see below)pwa
: the folder where the contents of the “compiled” mobile application will be copied, as well as theapi.php
entry point.- smartmaker-api
: the folder in which you will store the php controllers and mappers for your objects, which will be accessible via the api.php router in the
pwafolder. As well as a
smartmaker-api-prepend.phpfile which is used to factorise code and avoid having overly verbose php headers. ##Mapping dolibarr <-> application react Dolibarr objects can't be directly transposed into react, so we've developed a mapping system that allows you to map dolibarr objects to their react equivalent. Each dolibarr class that needs to be mapped can be mapped using a set of fine-tuned techniques, details of which can be found below. For example, for the dolibarr Company object you will find a dmCompany class in the smartAuth project. If your module provides a SmartInter object, for example, you can map its fields to react simply by implementing a dmSmartInter file. More details on the [[mapping dolibarr <ignore><-> react</ignore>]] ##api.php file This is where you implement the various entry points to the API dedicated to your application. ###The PHP router This php router includes the following grammar: * Route::action * action can be get post or put (delete is not yet implemented) * the 1st argument of the function is the name of the entry point you want on your api, so
Route::get('login'corresponds to the http request
GET /login. * the next argument gives the name of the PHP class to be requested * the next argument contains the name of the function to be used in this PHP class * the last argument indicates whether this is a route for which authentication is required or not This PHP router makes it extremely easy to 'track' the various actions possible on your API! For example, a
GET /logincalls the
indexfunction of the
AuthControllerclass and a
POST /logincalls the
loginfunction of the same class ... ``` Route::get('login', AuthController::class, 'index'); Route::post('login', AuthController::class, 'login'); ``` Want to implement a logout? It's easy: add a line to api.php ``` Route::post('logout', AuthController::class, 'logout', true); ``` And implement the
logoutfunction in your
AuthController` class …
/** * @api {post} /logout Logout * @apiDescription Logout and close session * @apiName PostLogout * @apiGroup Auth * */ public function logout($payload) {
Note: this function is of course already implemented natively in DoliMobile