SmarMaker - Documentation
Docs» en:back:start

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 This folder will contain all the source code for the mobile part (front-end in React, see below).
  • pwa the folder into which the contents of the “compiled” mobile application will be copied, as well as the entry point api.php
  • 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 pwa

As well as a file smartmaker-api-prepend.php which is used to factorise code and avoid having php headers that are too verbose.

Mapping dolibarr <-> react application

Dolibarr objects can't be directly transposed into react, so we've developed a mapping system that matches dolibarr objects with 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_-_react

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, for example 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 it 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 /login calls the index function of the AuthController class class and a POST /login calls the login function of this 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 logout function in your AuthController …

	/**
	 * @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

Previous Next

Made with ❤ by CAP-REL · SmartMaker · GNU AGPL v3+
Code source · Faire un don
SmarMaker - Documentation
Translations of this page:
  • Français
  • Deutsch
  • English
  • Español
  • Italiano
  • Nederlands

Table of Contents

Table of Contents

  • DoliMobile - Back (PHP)
    • Mapping dolibarr <-> react application
    • api.php file
      • The PHP router
  • SmartAuth
  • SmartMaker - Back (PHP)
    • Mapping Dolibarr - React
  • SmartMaker - Front (React)
    • Animations de pages
    • Architecture
    • Astuces
    • Calendar
    • Composants et pages
    • Configuration du Provider
    • Debug et Logs
    • Hooks SmartCommon
    • PWA (Progressive Web App)
    • Requêtes API
    • Routage
    • SmartCommon
    • Stockage de données
    • Synchronisation offline
    • Thèmes
    • Traductions
  • HowTo - Pas à pas - Votre première application
    • Développement PHP (back)
    • Développement React (front)
    • Première étape : Module Builder Dolibarr
    • SmartAuth
    • SmartBoot : Un squelette prêt à l'emploi
  • Formation SmartMaker
    • Module 1 : Fondamentaux JavaScript ES6+
      • Chapitre 1 : Variables et Scope
      • Chapitre 2 : Fonctions
      • Chapitre 3 : Programmation Asynchrone
      • Chapitre 4 : Modules ES6
    • Module 2 : Introduction à React
      • Chapitre 1 : Philosophie React
      • Chapitre 2 : JSX
      • Chapitre 3 : Composants
    • Module 3 : Hooks React Fondamentaux
      • Chapitre 1 : useState
      • Chapitre 2 : useEffect
      • Chapitre 3 : useRef
      • Chapitre 4 : useContext
    • Module 4 : React Avancé
      • Chapitre 1 : useCallback et useMemo
      • Chapitre 2 : Custom Hooks
      • Chapitre 3 : Redux et Redux Toolkit
    • Module 5 : Architecture SmartMaker
      • Chapitre 1 : Structure du projet
      • Chapitre 2 : Configuration
      • Chapitre 3 : Flux de données
    • Module 6 : SmartCommon - Composants
      • Chapitre 1 : Mise en page
      • Chapitre 2 : Navigation
      • Chapitre 3 : Formulaires
      • Chapitre 4 : Affichage
    • Module 7 : SmartCommon - Hooks
      • Chapitre 1 : useApi
      • Chapitre 2 : Gestion d'état
      • Chapitre 3 : Hooks utilitaires
      • Chapitre 4 : Synchronisation Offline
    • Module 8 : Backend API (PHP)
      • Chapitre 1 : Routage
      • Chapitre 2 : Controllers
      • Chapitre 3 : Mappers
      • Extrafields et formulaires dynamiques
    • Module 9 : Intégration complète
      • Chapitre 1 : Backend
      • Chapitre 2 : Frontend
      • Chapitre 3 : Déploiement
    • Module 10 : Fonctionnalités avancées
      • Chapitre 1 : Mode offline
      • Chapitre 2 : Internationalisation (i18n)
      • Chapitre 3 : Autres fonctionnalités
    • Module 11 : Bonnes pratiques
  • Démonstration
  • Start
  • Composants et pages
  • Show pagesource
  • Old revisions
  • Backlinks
  • Back to top