Environment and development tools: Difference between revisions

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
 
(70 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{TemplateDocDev}}
[[Category:Development]]
 
<!-- BEGIN origin interlang links -->
<!-- You can edit this section but do NOT remove these comments
    Links below will be automatically replicated on translated pages by PolyglotBot -->
[[fr:Outils_de_développement]]
[[es:Herramientas_de_Desarrollo]]
[[zh:开发环境与工具]]
<!-- END interlang links -->
 
{{TemplateDocDevEn}}


Every integrated development environment can be used.
Every integrated development environment can be used.
However, this is a list of tools highly recommanded to use. They are all famous and a good help as they are featurful and of high quality. They are used by most main Dolibarr developers. Above all, they are all free and Opensource.
However, this is a list of tools highly recommanded to use. They are all famous and a good help as they are featurful and of high quality. They are used by most main Dolibarr developers. Above all, they are all free and Opensource.


= [[File:Eclipsephp.jpg]] For every developer =
=[[File:Eclipsephp.jpg]] For every developer=


This is the recommended main tools but every tool compliant to Web, PHP, Mysql and Web standards can be used.
These are the recommended tools but any tool compliant with PHP, MySQL and Web standards can be used.


== An AMP server ==
==An AMP server==


* Apache, Mysql and PHP
*AMP means Apache + MariaDB + PHP


For Linux: Those 3 products are available in all Linux distribution by default.  
For Linux: These 3 products are available in almost all Linux distributions by default.  


For Windows: Install [http://www.wampserver.com/ WampServer 2] (Mysql database, Apache and PHP in an all in one package). This WAMP server offers MySql+Apache+PHP, with possibility to change version of any of this component with a simple click.
For Windows: Install [https://www.wampserver.com/WampServer] (MariaDB SQL database, Apache and PHP in an all-in-one package) or a comparable system environment (like XAMPP).


== Firefox and plugins ==
The WAMP server offers MariaDB+Apache+PHP, with the option to change the version of any component with a simple click.
* Firefox 3.0 with plugins:
** Firebug + Firecookie + FirePHP ,  
** HTML Validator,
** Phplangeditor and Dictionnaries of any languages you plan to translate,
** User Agent Switcher to simulate usage of smartphones.
** Selenium IDE,
** Cert Viewer Plus if you plan to make tests with HTTPS,
** QuickProxy if you want to switch quickly on proxy tools (WebScarab),
You can download this on web site http://www.firefox.com


== SquirrelSQL ==
==Webbrowser (Chrome / Firefox) + plugins==
* SquirrelSQL for database administration
You can download it at http://squirrel-sql.sf.net


== Eclipse and plugins ==
*Chrome + plugins
=== Install Eclipse ===
We recommend to use the following package of Eclipse:
{{DownloadEclipse}}


Also any version available on [http://www.eclipse.org Eclipse we site] is possible.
You can download Chrome from https://www.chrome.com
 
=== Install plugin Eclipse for PHP: PDT. ===
If you installed Eclipse version defined previously, all you have to do is using process Help -> Install new software -> Add -> Archive to add module:
 
{{DownloadEclipsePDT}}


=== Setup Eclipse to get sources ===
*Firefox + plugins
Once Eclipse is installed, you can connect to GIT repository to get last development version.


For this see page [[FAQ Get,update GIT project sources]].
You can download this on web site https://www.firefox.com


= [[File:Computer.png]]  Optional =
or the new Firefox Developer Edition: https://www.mozilla.org/de/firefox/developer/


== If you manage other projects with SVN ==
==A database administration tool==
* Install Eclipse plugin for SVN: SubClipse
For this, use the '''Find And Install process''' and add the SVN update URL:


http://subclipse.tigris.org/install.html
Using a heavy database manging client is more productive than using web tools like phpmyadmin. For such a client, you can try


or
*HeidiSQL
* Install Eclispe plugin for SVN: Subversive
*SquirrelSQL
*DBeaver


http://community.polarion.com/projects/subversive/download/eclipse/2.0/ganymede-site/ - [required] Subversive SVN Connectors
Go on official web site of this product to download them.


http://community.polarion.com/projects/subversive/download/integrations/ganymede-site/ - [optional] Subversive Integrations
==An IDE and plugins==


== If you want to make Perl scripts ==
You must then have a development IDE that support PHP, for example Eclipse PHP, PHPStorm or VSCode.
* Install the Eclipse plugin for Perl: EPIC
For this, use the '''Find And Install process''' and add the update URL: http://e-p-i-c.sourceforge.net/updates


== If you want to develop modules with the UML2Dolibarr generator ==
===Eclipse===
====Install Eclipse====
We recommend to use an Eclipse version provided on eclipse.org. For example: {{DownloadEclipse}}


A method to generate code of a module from UML is currently on work.
Also any version available on [http://www.eclipse.org Eclipse web site] is possible.
More information on page [[UML2Dolibarr - Build a module using MDA|Building a module using MDA]].  
To use it, you must install the following components (If you install the previously recommanded version of Eclipse, all of this is already done):


* Install TopCased 1.4+: http://www.topcased.org
Once Eclipse is installed, it is recommanded to setup the following parameters:
{{EclipseStandardSetup}}


* Install Acceleo 2.2.1+: For this, user menu '''Find And Install''' and add update URL: http://www.acceleo.org/update/
====Install plugin Eclipse for PHP: PDT.====
If you installed Eclipse version and PDT is not included, all you have to do is using process Help -> Install new software -> Add -> Archive to add module:


* Install UML2Dolibarr
{{DownloadEclipsePDT}}
For this, get the procject with command:
<source lang="bash">
svn checkout svn://svn.forge.objectweb.org/svnroot/acceleo/trunk/modules/community/uml21/dolibarr/trunk/
</source>
and import it into Eclipse.


== If you are using Windows ==
Once installed, you must also setup PDT into Eclipse as explained into chapter [[Environment_and_development_tools_-_Optionnal_components#From_Eclipse]]


* Notepad++ (for those which can't stand java or using a computer too old for Eclipse).
====Setup Eclipse to get sources====
Once Eclipse is installed, you can connect to GIT repository to get last development version.


* WinMerge (to compare files and directories)
For this see page [[FAQ Get,update GIT project sources]].
 
* CygWin (to have the "patch" command)
 
== To make FirePHP Debug ==
If using Ubuntu, you can also complete PHP with FirePHP module by running
<source lang="php">
pear channel-discover pear.firephp.org
pear install firephp/FirePHPCore
</source>
 
== If you want to make step by step debugging or tunning (XDebug) ==
* To add global tuning information for pages on your browser status bar, add environment variable DOL_TUNING to 1 into Apache. For this, just add the following line into your apache.conf:
<source lang="ini">
SetEnv DOL_TUNING 1
</source>
Then, check that your browser does not have options to block changing of status bar by javascript.
 
* Install XDebug:
=== [[File:Logo_windows.png|24px]] In Windows ===
* Download dll file '''php_debug_xxx.dll''' on http://www.xdebug.org and store it in directory /ext of php. Then enable plugin.
 
* Modify php.ini file to add parameters:
<source lang="ini">
[xdebug]
xdebug.remote_enable=on
xdebug.remote_handle=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.show_local_vars=off
xdebug.profiler_output_dir=c:/temp
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
</source>
 
=== [[File:Logo_ubuntu.png|24px]] In Ubuntu / Linux ===
* Install package '''php-xdebug''':
<source lang="bash">
sudo apt-get install php5-xdebug
</source>
 
* Modify xdebug.ini to add parameters after the line zend_extension=xxx (or similar):
<source lang="ini">
; With xdebug 2.1 and more
xdebug.remote_enable=on
xdebug.remote_handle=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.show_local_vars=off
xdebug.profiler_output_dir=/var/tmp
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
; Add also this with xdebug 2.2 and more
xdebug.show_mem_delta=1
xdebug.trace_output_dir=/var/tmp
xdebug.auto_trace=0
xdebug.trace_enable_trigger=1
</source>
 
=== [[File:Eclipsephp.jpg|24px]] Eclipse configuration ===
* Open Eclipse. In Window->Preferences->General->Web Browser, select external web browser, and set it to Default system web browser.
 
* Go into the debug section, by Window->Preferences->PHP->Debug, and set the PHP Debugger option to XDebug (by default this is set to the Zend Debugger). Note the chekbox “Break at first line” in this page as well – you can change this later on, as required.  


* After you’ve applied your changes, go into the PHP Debug prespective, and go to menu Debug Configurations… Here, make sure the Server Debugger is set to XDebug, and that the PHP server points to http://localhost/ or an appropriate server location. The file section should point to the file to be debugged, relative to your workspace, the relative path maybe something /dolibarr/htdocs/index.php.


* Check the URL section to see whether it points to the correct location – if not, make sure you uncheck the “Auto-Generate” check box, and enter in the correct location. Apply the changes and close the dialog box.
====Codium====
Codium is the Free version of VSCode, so the following documentation will probably be compatible with vscode too.


* You should now be ready to debug Dolibarr. Click on Run->Debug or F11 to enable debugging, Eclipse should switch to the Debug View, and the page should start loading in your external browser. If “Break at First Line” checkbox was checked previously, then the program would have “stopped” at the first line. You can step into or step over subsequent lines using the controls on your top left corner. Alternatively, you can place breakpoints at various locations and stop code execution there as well.
Here is the list of recommended add-ons:


*PHP Intelephense
*phpdoc-comment
*PHPUnit
*PHP CS Fixer


Then to analyze files generated by XDebug profiling, you must call the page by adding parameter XDEBUG_PROFILE=1 to generate the file and then install KCacheGrind (Linux) or WinCacheGrind (Windows) to analyze them.
If you develop add-ons for Dolibarr, you will appreciate having the definitions of functions and other objects of dolibarr without having to source the complete tree of dolibarr...


== To develop or use Quality controls (PHPUnit, PHPCodeSniffer, PHPCpd, PHPDepends) ==
All this is done by retrieving the stubs from <nowiki>https://packagist.org/packages/caprel/dolibarr-stubs</nowiki>.
=== From Eclipse ===
You can also optionnally install The PHP Tools integration (PTI) using the Eclipse plugin installer menu with this following URL:


http://www.phpsrc.org/eclipse/pti/
Once the stub is downloaded / or installed following the doc, remember to add the dolibarr-stubs file to the list of stubs of your codium, edit the file ~/.config/VSCodium/User/settings.json
<syntaxhighlight lang="json">
"intelephense.stubs": [
  "apache",
  "intl",
  "standard",
  "/media/erics/stockage/tmp/dolibarr/stubs",
],
"intelephense.environment.includePaths": [
  "/media/erics/stockage/tmp/dolibarr/stubs",
],
</syntaxhighlight>


If you do so, menu to launch tools tests are available in your Eclipse menu.
===Visual Studio Code (VSCode)===


Modify your Eclipse setup (Windows-Preferences-PHPTools-PHPCodeSniffer) to add a new directory standard found into''' dev/codesniffer'''.
If you choosed VSCode, you can should the following plugin:


Modify your Eclipse setup (Windows-Preferences-PHPTools-PHPUnit) like on screen shot (click to zoom):
*PHP Intelephense
*Git Graph
*EditorConfig so VSCode will automatically use the setup of the project defined into .editorconfig


[[File:Eclipse setup PHPUnit.png|100px]]
==Git Hooks==


If not, you must install and run PHPUnit and other quality tools manually from command line.
===Install Pre-commit githook===
You can use git hooks to check the syntax of the file you commit and cancel (or better autofix) the commit if something is wrong.  


=== From Command Line ===
Instruction to install such a precommit hook is available on this file:
==== Instal PHPUnit ====
* Download a release archive from http://pear.phpunit.de/get/ and extract it to a directory that is listed in the include_path of your php.ini configuration file.
* Prepare the phpunit script:
** For Linux: Rename the phpunit.php script to phpunit and replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
** For Windows: Replace the @php_bin@ string in file phpunit.bat with the path of your PHP command-line interpreter and @bin_dir@ string with the path of the PHPunit directory.
** Edit your Path to inclulde PHPunit directory
** Make script runnable (chmod +x phpunit on Linux).
* Prepare the PHPUnit/Util/PHP.php script:
** Replace the @php_bin@ string if it exists in file it with the path to your PHP command-line interpreter (usually /usr/bin/php).
* Module xdebug can also be required if you plan to make reporting of test code covering.


==== Execute PHPUnit tests ====
https://github.com/Dolibarr/dolibarr/tree/develop/dev/setup/pre-commit
* Go into directory '''/test''' of sources. Read file '''README''' to know the process to execute a unit test campaign.


==== Install other quality tools ====
* Take a look at tools documentation (PHPCodeSniffer, PHPPcd, PHPDepends).


== To develop or use Selenium tests ==
Such hooks will work when using git on command line but may also work when committing using your common IDE (it has been validated with Eclipse and VSC).  
=== From Firefox ===
==== Install plugin for Firefox Selenium IDE ====
* Download file of plugin "Selenium IDE" for Firefox.
* Add it into firefox in menu Tools - Complementary modules.


==== Execute Selenium tests ====
Once installed, the hook will start on your next commit to re-format your code, so your code will always match the coding syntax rules. If everybody enable this hook, everybody will use the same coding syntax rule, so it is highly recommended to enable it if you can. If something is wrong in the syntax, the commit will be immediately canceled. If it can be fixed automatically, phpcbf, installed during the install of the precommit hook, will fix it so you just have to try the commit a second time to have it validated.
* Go into menu Tools - Selinum IDE of Firefox.
* Open xml file of the suite tests.
* Execute the test.


== To build Doxygen documentation ==
=[[File:Computer.png]]  Optional=
* Install Doxygen available for download at http://www.doxygen.org (or install package doxygen with Ubuntu).
There are a lot of more components you can install to get more technologies support:  
* Install Eclipse plugin by adding source http://download.gna.org/eclox/update/ into your Eclipse update setup. Then setup your Eclipse (Window-Preferences-Doxygen) to define path to Doxygen tool.
[[Environment and development tools - Optionnal components]]

Latest revision as of 19:34, 4 April 2026


Every integrated development environment can be used. However, this is a list of tools highly recommanded to use. They are all famous and a good help as they are featurful and of high quality. They are used by most main Dolibarr developers. Above all, they are all free and Opensource.

Eclipsephp.jpg For every developer

These are the recommended tools but any tool compliant with PHP, MySQL and Web standards can be used.

An AMP server

  • AMP means Apache + MariaDB + PHP

For Linux: These 3 products are available in almost all Linux distributions by default.

For Windows: Install [1] (MariaDB SQL database, Apache and PHP in an all-in-one package) or a comparable system environment (like XAMPP).

The WAMP server offers MariaDB+Apache+PHP, with the option to change the version of any component with a simple click.

Webbrowser (Chrome / Firefox) + plugins

  • Chrome + plugins

You can download Chrome from https://www.chrome.com

  • Firefox + plugins

You can download this on web site https://www.firefox.com

or the new Firefox Developer Edition: https://www.mozilla.org/de/firefox/developer/

A database administration tool

Using a heavy database manging client is more productive than using web tools like phpmyadmin. For such a client, you can try

  • HeidiSQL
  • SquirrelSQL
  • DBeaver

Go on official web site of this product to download them.

An IDE and plugins

You must then have a development IDE that support PHP, for example Eclipse PHP, PHPStorm or VSCode.

Eclipse

Install Eclipse

We recommend to use an Eclipse version provided on eclipse.org. For example: https://eclipse.org/pdt/

Also any version available on Eclipse web site is possible.

Once Eclipse is installed, it is recommanded to setup the following parameters:

  • Window - Preferences - General - Workspace - Text file encoding -> UTF8
  • Window - Preferences - General - Workspace - New text file line delimiter -> Unix
  • Window - Preferences - General - Compare/Patch - Ignore white spaces -> Yes
  • Window - Preferences - General - Editor - Text editors - Tab delimiter length -> 4
  • Window - Preferences - General - Editor - Text editors - Insert spaces for tab -> No
  • Window - Preferences - General - Editor - File Association -> Add *.lang associated to "Text Editor"
  • Note: You can also disable Windows - Preferences - Java - Editor - Content Assist - Auto Activation

And if PDT is installed (see later):

  • Window - Preferences - PHP - Code Style - Formatter - Tab policy -> Tab
  • Window - Preferences - PHP - Code Style - Formatter - Default indentation for wrapped line -> 1
  • Window - Preferences - PHP - Code Style - Formatter - Default indentation for array initializer -> 0
  • Window - Preferences - PHP - Editor - Typing - Uncheck "When Pasting Adjust Indentation" (keeping this option checked create corruption of text files by adding bad end of line characters)
  • Window - Preferences - PHP - Code Style - Formatter - Use the profile provided into dev/setup/eclipse/PSR-12 [built-in].xml as Eclipse syntax formatter.
  • Note: You can also disable Windows - Preferences - PHP - Editor - Content Assist - Auto Activation

Install plugin Eclipse for PHP: PDT.

If you installed Eclipse version and PDT is not included, all you have to do is using process Help -> Install new software -> Add -> Archive to add module:

https://download.eclipse.org/releases/xxx - xxx = version

Or from the GUI of any Eclipse =>Install New Software =>Work With Kepler => Wait until list display =>General Purpose Tools Check PHP development tools (PDT)=>Install

Once installed, you must also setup PDT into Eclipse as explained into chapter Environment_and_development_tools_-_Optionnal_components#From_Eclipse

Setup Eclipse to get sources

Once Eclipse is installed, you can connect to GIT repository to get last development version.

For this see page FAQ Get,update GIT project sources.


Codium

Codium is the Free version of VSCode, so the following documentation will probably be compatible with vscode too.

Here is the list of recommended add-ons:

  • PHP Intelephense
  • phpdoc-comment
  • PHPUnit
  • PHP CS Fixer

If you develop add-ons for Dolibarr, you will appreciate having the definitions of functions and other objects of dolibarr without having to source the complete tree of dolibarr...

All this is done by retrieving the stubs from https://packagist.org/packages/caprel/dolibarr-stubs.

Once the stub is downloaded / or installed following the doc, remember to add the dolibarr-stubs file to the list of stubs of your codium, edit the file ~/.config/VSCodium/User/settings.json

"intelephense.stubs": [
  "apache",
  "intl",
  "standard",
  "/media/erics/stockage/tmp/dolibarr/stubs",
 ],
 "intelephense.environment.includePaths": [
  "/media/erics/stockage/tmp/dolibarr/stubs",
 ],

Visual Studio Code (VSCode)

If you choosed VSCode, you can should the following plugin:

  • PHP Intelephense
  • Git Graph
  • EditorConfig so VSCode will automatically use the setup of the project defined into .editorconfig

Git Hooks

Install Pre-commit githook

You can use git hooks to check the syntax of the file you commit and cancel (or better autofix) the commit if something is wrong.

Instruction to install such a precommit hook is available on this file:

https://github.com/Dolibarr/dolibarr/tree/develop/dev/setup/pre-commit


Such hooks will work when using git on command line but may also work when committing using your common IDE (it has been validated with Eclipse and VSC).

Once installed, the hook will start on your next commit to re-format your code, so your code will always match the coding syntax rules. If everybody enable this hook, everybody will use the same coding syntax rule, so it is highly recommended to enable it if you can. If something is wrong in the syntax, the commit will be immediately canceled. If it can be fixed automatically, phpcbf, installed during the install of the precommit hook, will fix it so you just have to try the commit a second time to have it validated.

Computer.png Optional

There are a lot of more components you can install to get more technologies support: Environment and development tools - Optionnal components