Aller à : navigation, rechercher

Maarch Courrier/1.5/fr/Install/DeveloperHandbook

Maarch Developer handbook

Retrieve MaarchCourrier

Ubuntu is Highly Recommended !

cd /var/www/html/
mkdir MaarchCourrier
cd MaarchCourrier
git clone .
git config core.fileMode false

Install Maarch from :

Install composer from :

mv composer.phar /usr/local/bin/composer

Install slimFramework from (Optionnal, already downloaded during installation)

cd /var/www/html/MaarchCourrier
composer require slim/slim
composer dump-autoload
Install respect/validation
cd /var/www/html/MaarchCourrier
composer require respect/validation

Tuto slim framework 3 :


Install npm from (Optionnal, already downloaded during installation)

sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install npm@latest -g
cd /var/www/html/MaarchCourrier
npm install --production

(If nodejs is in older version (0.10.x)) :

- Using Ubuntu

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

- Using Debian, as root

curl -sL | bash -
apt-get install -y nodejs

Tuto angular 2 :

Creates a vhost on apache

sudo nano /etc/apache2/sites-available/MaarchCourrier.conf
listen 8090
<VirtualHost *:8090>
        DocumentRoot "/var/www/html/MaarchCourrier"
        ServerName maarchcourrier
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

       Options -Indexes
       Options FollowSymLinks Includes ExecCGI
       <FilesMatch ".*">
        Order deny,allow
        Deny from all
       # Root to allow index.php
       <FilesMatch "^$">
        Order allow,deny
         Allow from all
       # Core root
       <FilesMatch "^(index|ws_server|static|merged_js|merged_css|reopen|applet_launcher|applet_controller|log)\.php$">
        Order allow,deny
        Allow from all
       # App static files
       <FilesMatch "\.(css|js|jpg|jpeg|png|gif|ttf|woff|woff2)$">
        Order allow,deny
        Allow from all
       # App tools files
       <FilesMatch "\.(htm|html|jar|jnlp)$">
        Order allow,deny
        Allow from all

A partir de Apache 2.4, il faut éditer le fichier /etc/apache2/apache2.conf, et modifier cette partie comme ceci :
<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
sudo a2enmod rewrite
sudo a2ensite MaarchCourrier.conf

Create your own develop branch

Lorsque l’on commence un développement, on créé sa branche à partir de la branche develop. Une branche personnelle est donc créée à chaque fois que l’on souhaite faire une correction ou une évolution de code. Elle devra être fusionnée avec la branche develop une fois que les développements ont été testés unitairement et fonctionnellement.

1. checkout de la branche develop

git checkout -b develop origin/develop

2. création de la branche locale personnelle à partir de la branche develop

git branch lgi-feat-admin-status develop

3. basculement sur la branche personnelle

git checkout lgi-feat-admin-status

Merge develop in your personal branch

Merge de la branche develop vers sa branche personnelle

1. Se positionner sur la branche develop et la mettre à jour

git checkout develop
git pull

2. On revient sur sa branche personnelle

git checkout lgi-feat-admin-status

3. On merge la branche develop vers sa branche personnelle

git merge develop

-> read

Commit your development on develop branch

#on your local branch you have to commit
git commit -m "[MESSAGE]"

git checkout develop
git pull
git checkout lgi-feat-admin-status

git merge develop
# You may need to resolve conflict

git checkout develop
git pull --rebase
git merge lgi-feat-admin-status
git rebase -i
git push

To jump from a tag to another tag

git checkout tags/17.06.5 -b 17.06.5

To delete a local tag

git tag -d 17.06-RC.5

To delete a local branch

git branch -d 17.11

To update local repository (when remote branch was deleted)

git fetch -p

Files header


* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.

Coding standards


Coding style guide


Documentation style guide

use phpdoc -> gives samples

Tests your REST webservices

UML specifications



Writes the test first : Sample of testing a controller

require_once __DIR__.'/define.php';

class StatusControllerTest extends PHPUnit_Framework_TestCase
    public function testGetList()
        $action = new \Core\Controllers\StatusController();
        $environment = \Slim\Http\Environment::mock(
                'REQUEST_METHOD' => 'GET',
        $request = \Slim\Http\Request::createFromEnvironment($environment);
        $response = new \Slim\Http\Response();
        $response = $action->getList($request, $response, []);


command to test with phpunit :

cd /var/www/html/MaarchCourrier
phpunit --coverage-html /tmp/tests --whitelist core/Test/


Pour les utilisateurs Linux, il est possible de personnaliser votre console avec le nom de la branche courante en entête. Pour ce faire : Ouvrir le fichier ~/.bashrc Ajoutez les lignes suivantes :

function parse_git_branch {
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1]/"

GREEN=$(tput setaf 2) 
DEFAULT=$(tput sgr0)

NPM : How to install a new plugin

First of all, NPM is working with a package.json file which reference every plugin installed on MaarchCourrier.

If you want to install/add a new package to the application, you should pass by this file, every decent package should normally be present on NPM.

Check the NPM webpage associated with your package and you should see a npm command like “npm install jquery” for the jquery plugin, add it “--save” to save/write the package in the package.json file automatically, e.g “npm install jquery --save”.

Launch the command in a terminal at the application root and you should see NPM working.

Your package is going to be installed in the node_modules folder (located at the application root).

Once your package is downloaded, you got to load it in the application, to do so, open the merged_jsAbstract file and add the path line corresponding to your minify js file package e.g readfile('node_modules/jquery/dist/jquery.min.js');

Your package is now loaded in the application ;)

Angular in MaarchCourrier

For MaarchCourrier 17.06 :

There is 2 modes for Angular in our application, a Production Mode and a Developer Mode. The Production Mode consists on a only bundled file regrouping all angular files (which is faster).

Production Mode is set by default in our application, to change it, you have to set the PROD_MODE variable in apps/maarch_entreprise/define.php to false.

When Production Mode is false, the application will load each angular file one by one (which is slower).

Angular (2) is working with TypeScript files (.ts). TypeScript describe itself as “a typed superset of JavaScript that compiles to JavaScript”, so when you are developing with Angular and with TypeScript files, you should launch this command into a terminal “npm run build:watch”.

This command will watch your TypeScript files and transpile them into JavaScript files every time you save them. Finally, when you have finished your developments, don’t forget to rebuild the bundled file used in Production Mode, to do so, launch this command into a terminal “npm run build-prod”.

For MaarchCourrier 18.04 and more :

The way of angular compilation is different in this version of MaarchCourrier. New commands are :

npm run build => compile angular

npm run build-watch => compile angular automatically when you edit ts files

npm run build-prod => compile angular for production environment (administration loading will be very fast !)

Those commands will generate dist directory to the root of application

PROD_MODE variable in apps/maarch_entreprise/define.php is not use anymore

Due to uglify problems on older firefox versions, we have to delete some directories before running "npm run build-prod"

On branch 18.04, delete "node_modules/@angular/cli/node_modules/uglify-es" and "node_modules/@angular/cli/node_modules/uglifyjs-webpack-plugin"
On branch develop, delete "node_modules/@angular-devkit/build-angular/node_modules/uglify-es" and "node_modules/@angular-devkit/build-angular/node_modules/uglifyjs-webpack-plugin"

To know commits between 2 tags

git log --pretty=oneline 17.06.1..17.06.2

Extract database

Pour générer la documentation par exemple (

psql maarchdatabase

\d+ *.*;  (pour extraire toutes les tables)
\d+ cases_res; (pour extraire une seule table)

\o /tmp/database.txt  (pour envoyer le résultat dans un fichier txt)