Skip to content
Snippets Groups Projects
Commit 509aad9b authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix README

parent 3b2eb97d
No related branches found
No related tags found
No related merge requests found
API REST howto
==============
API REST
========
This directory contains files to make Dolibarr a server of REST Web Services.
It depends on external library Restler.
## Integrate your ERP with any other applications using Dolibarr APIs, Triggers or Hooks
This module provides the service to make Dolibarr a server of REST Web Services. It depends on external library Restler.
Extract any data or push insert, update or delete record using our new REST APIs. Using standard HTTP and Json format, it is compatible with any language (PHP, Java, Ruby, Python, C#, C++, JavaScript, JQuery, Basic, ...). Use the embedded APIs explorer tool to test APIs or get generated URLs to use in your own code.
Explore the api
---------------
You can explore API method by using web interface : https://**yourdolibarr.tld**/mydolibarr/api/admin/explorer.php (replace **yourdolibarr.tld** by real hostname of your Dolibarr installation)
<div align="center">
<img class="imgdoc" src="https://www.dolibarr.org//images/doc_apirest.png" alt="Dolibarr API explorer"/>
</div>
Access to the API
Explore the APIs
----------------
You can explore all available APIs by using the API explorer : [**yourdolibarr.tld**/api/index.php/explorer](../api/index.php/explorer) (replace **yourdolibarr.tld** by real hostname of your Dolibarr installation)
Access to an API
-----------------
> **Warning : access to the API should (or better : must!) be secured with SSL connection**
> **Warning : access to any API should (or better : must!) be secured with SSL connection**
To access to the API you need a token to identify. When you access the API for the first time, you need to log in with user name and password to get a token. **Only** this token will allow to access API with.
To access to the API you need a token to identify. **Only** this token will allow to access API with.
The token is dedicated to a user and it **must** be put into requests as **DOLAPIKEY** parameter in HTTP header (or among URL parameters, but this is less secured).
To log in with the API, use this uri : https://**yourdolibarr.tld**/mydolibarr/api/index.php/login?login=**username**&password=**password** (replace bold strings with real values)
To get a token you can:
The token will be saved by Dolibarr for next user accesses to the API and it **must** be put into request uri as **api_key** parameter.
* Edit the user card to set the value of token. Each user can have a different token.
* or Call the *login* API with login and password. This will return the value of token for the user used to login.
Then call other services with
https://**yourdolibarr.tld**/mydolibarr/api/index.php/otherservice?api_key=**api_key**
https://**yourdolibarr.tld**/mydolibarr/api/index.php/otherservice?DOLAPIKEY=**api_key**
Develop the API
---------------
Develop an API
--------------
The API uses Lucarast Restler framework. Please check documentation https://www.luracast.com/products/restler and examples http://help.luracast.com/restler/examples/
Github contains also usefull informations : https://github.com/Luracast/Restler
To implement it into Dolibarr, we need to create a specific class for object we want to use. A skeleton file is available into /dev directory : *skeleton_api_class.class.php*
To implement it into Dolibarr, you need to create a specific class for object we want to use. A skeleton file is available into /modulebuilder/class directory : *api_mymodule_class.class.php*
The API class file must be put into object class directory, with specific file name. By example, API class file for '*myobject*' must be put as : /htdocs/*myobject*/class/api_*myobject*.class.php. Class must be named **MyobjectApi**.
If a module provide several object, use a different name for '*myobject*' and put the file into the same directory.
If a module provide several object, use a different name for *'myobject'* and put the file into the same directory.
**Define url for methods**
......
Dolibarr Module Template (aka My Module)
========================================
Module Builder
==============
This is a full featured module template for Dolibarr.
It's a tool for module developers to kickstart their project and give an hands-on sample of which features Dolibarr has to offer for module development.
This is a module to provide embedded tools to develop your own application/features inside Dolibarr ERP CRM software.
It provide tools for module developers to kickstart their project and give an hands-on sample of which features Dolibarr
has to offer for module development.
If you don't need to develop your own module/application, you just don't need this.
After enabling this module, you should find features to generate or edit modules/application from menu *Home - Admin tools - Module builder*
If you're not a module developer you have no use for this.
Documentation
-------------
......@@ -12,204 +17,3 @@ Documentation
[Module tutorial](https://wiki.dolibarr.org/index.php/Module_development)
[Dolibarr development](https://wiki.dolibarr.org/index.php/Developer_documentation)
### Translations
Dolibarr uses [Transifex](https://transifex.com) to manage it's translations.
This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory.
For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation).
There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
Install
-------
### Manually
- Make sure Dolibarr is already installed and configured on your workstation or development server.
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
- Find the following lines:
```php
//$dolibarr_main_url_root_alt ...
//$dolibarr_main_document_root_alt ...
```
- Uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
For example :
- UNIX:
```php
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
$dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
```
- Windows:
```php
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
$dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
```
For more information about the ```conf.php``` file take a look at the conf.php.example file.
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
*(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)*
```sh
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule
```
- Install [Composer](https://getcomposer.org) dependencies:
```sh
composer install
```
Follow the [final steps](#final_steps).
### Using [Composer](https://getcomposer.org)
Require this repository from Dolibarr's composer:
```json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/dolibarr/dolibarr-module-template"
}
],
"require": {
"dolibarr/mymodule": "dev-master"
}
}
```
Run
```sh
composer update
```
Follow the [final steps](#final_steps).
### <a name="final_steps"></a>Final steps
From your browser:
- Log into Dolibarr as a super-administrator
- Under "Setup" -> "Other setup", set ```MAIN_FEATURES_LEVEL``` to ```2```
- Go to "Setup" -> "Modules"
- The module is under one of the tabs
- You should now be able to enable the new module and start coding ;)
Provided tools
--------------
### Starting a new module
A [script](dev/newmodule.sh) allows you to rename most of the code to your own module name.
It requires ```find```, ```sed``` and ```rename``` commands on your system.
Just make sure you provide a CamelCase name.
```sh
./dev/newmodule.sh [NewName]
```
Some work still has to be done manually:
- Rename the directory holding the code
- Maybe rename some other bits (Search for 'my' in filenames and code)
- Update your module ID in the module descriptor
- Update your language files
- Keywords based on the module ID
- String referencing the template
- Remove the features you don't plan to use
- Fill the copyright notices at the top of each file
- Add your logo: see [images README](dev/img/README.md) for specifications
- Start a new GIT history
```
git checkout --orphan [new_branch_name]
```
- Build an awesome module ;)
### Composer scripts
Only the main commands are listed here.
See the [composer comments](composer-comments.md) or the [composer.json](composer.json) itself for more informations.
#### Check
Run a linter, a PHP compatibility version checker and checks coding style.
```sh
composer check
```
#### Test
Run unit and functional tests.
```sh
composer test
```
#### Doc
Build code and user documentation.
#### Release
Run the checks and tests then build a distribution ZIP.
```sh
composer release
```
#### Git hooks
Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided.
These are just wrappers calling composer scripts.
They ensure best practices are followed during module development.
Install:
```sh
composer git_hooks_install
```
Remove:
```sh
composer git_hooks_remove
```
## Publishing the module
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
Templates for required images and texts are [provided](dev/dolistore).
Check the dedicated [README](dev/dolistore/README.md) for more informations.
Licenses
--------
### Main code
![GPLv3 logo](img/gplv3.png)
GPLv3 or (at your option) any later version.
See [COPYING](COPYING) for more information.
### Other Licenses
#### [Parsedown](http://parsedown.org/)
Used to display this README in the module's about page.
Licensed under MIT.
#### [GNU Licenses logos](https://www.gnu.org/graphics/license-logos.html)
Public domain
#### Documentation
All texts and readmes.
![GFDL logo](img/gfdl.png)
......@@ -4,3 +4,97 @@
MyModuleDescription
Other modules are available on <a href="https://www.dolistore.com" target="_new">Dolistore.com</a>.
### Translations
This module contains a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service.
Translations can be define manually by editing files into directories [langs](langs).
<!--
For more informations, see the [translator's documentation](https://wiki.dolibarr.org/index.php/Translator_documentation).
There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module.
-->
<!--
Install
-------
### Manually
- Make sure Dolibarr is already installed and configured on your workstation or development server.
- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file
- Find the following lines:
```php
//$dolibarr_main_url_root_alt ...
//$dolibarr_main_document_root_alt ...
```
- And uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation
For example :
- UNIX:
```php
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
$dolibarr_main_document_root = '/var/www/Dolibarr/htdocs';
$dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom';
```
- Windows:
```php
$dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs';
$dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs';
$dolibarr_main_url_root_alt = '/custom';
$dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom';
```
For more information about the ```conf.php``` file take a look at the conf.php.example file.
- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule```
```sh
git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule
```
### <a name="final_steps"></a>Final steps
From your browser:
- Log into Dolibarr as a super-administrator
- Go to "Setup" -> "Modules"
- You should now be able to find and enable the module
## Publishing the module
The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com).
Templates for required images and texts are [provided](dev/dolistore).
Check the dedicated [README](dev/dolistore/README.md) for more informations.
-->
Licenses
--------
### Main code
![GPLv3 logo](img/gplv3.png)
GPLv3 or (at your option) any later version.
See [COPYING](COPYING) for more information.
#### Documentation
All texts and readmes.
![GFDL logo](img/gfdl.png)
# Git hooks
Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided.
These are just wrappers calling composer scripts.
They ensure best practices are followed during module development.
Install:
```sh
composer git_hooks_install
```
Remove:
```sh
composer git_hooks_remove
```
......@@ -666,11 +666,18 @@ div.myavailability {
margin-bottom: 12px;
}
/* For the long description of module */
.moduledesclong p img, .moduledesclong p a img {
max-width: 90% !important;
height: auto !important;
}
.imgdoc {
margin: 18px;
border: 1px solid #ccc;
box-shadow: 1px 1px 25px #aaa;
max-width: calc(100% - 56px);
}
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
......
......@@ -667,11 +667,18 @@ div.myavailability {
margin-bottom: 12px;
}
/* For the long description of module */
.moduledesclong p img,.moduledesclong p a img {
max-width: 90% !important;
height: auto !important;
}
.imgdoc {
margin: 18px;
border: 1px solid #ccc;
box-shadow: 1px 1px 25px #aaa;
max-width: calc(100% - 56px);
}
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment