Merge branch 'master' of ssh://rhea.netlor.fr:2222/monarc/MonarcAppBO

pull/1/head
Cyril Rouyer 2017-02-28 17:12:38 +01:00
commit f211f65bad
26 changed files with 7170 additions and 152 deletions

2
.gitignore vendored
View File

@ -6,8 +6,8 @@ nbproject
.idea
.project
.settings
composer.lock
vendor/bin
composer.json
migrations
*.sublime-*
vendor/

147
README.md
View File

@ -1,6 +1,8 @@
Skeleton Monarc Project
=======================
*Disclaimer: This is a work in progress and software is still in alpha stage.*
Introduction
------------
Skeleton Monarc Project.
@ -8,26 +10,88 @@ Skeleton Monarc Project.
Installation
------------
PHP & MySQL
-----------
Install PHP (version 7.0 recommended) with Apache (or Nginx) with extensions : xml, mbstring, mysql, zip, unzip, mcrypt, intl, imagick (extension php)
For Apache add mods : rewrite, ssl (a2enmod)
Install MySQL (version 5.7 recommended) or MariaDb equivalent
Using Composer (recommended)
----------------------------
The recommended way to get a working copy of this project is to clone the repository
and use `composer` to install dependencies using the `create-project` command:
curl -s https://getcomposer.org/installer | php --
php composer.phar create-project -sdev --repository="https://rhea.netlor.fr/monarc/skeleton/raw/master/packages.json" monarc/skeleton ./monarc
Alternately, clone the repository and manually invoke `composer` using the shipped
`composer.phar`:
cd my/project/dir
git clone ssh://gogs@rhea.netlor.fr:2222/monarc/skeleton.git ./monarc
git clone ssh://github.com/CASES-LU/MonarcAppBO.git ./monarc
cd monarc
php composer.phar self-update
php composer.phar install -o
php composer.phar install -o (modifier le package.json deux errreurs passer en dev-beta le core et il y a un / en trop pour zm-core)
(The `self-update` directive is to ensure you have an up-to-date `composer.phar`
available.)
![Arbo](public/img/arbo1.png "Arbo")
Databases
---------
Create 2 databases:
CREATE DATABASE monarc_master;
CREATE DATABASE monarc_common;
Change Sql Mode in my.cnf:
sql-mode = MYSQL40
There is 2 databases:
* monarc_common contain models and data create by smile.
* monarc_master contain all user and authentication information
Symbolics links
---------------
The project is splited on 2 parts :
* an Api in charge of retrieve data
* an interface to display data
The Api is not direct modules of the project but libraries.
You must create modules with symbolics link to libraries
Create 2 symbolics links at project root:
mkdir module
cd module
ln -s ./../vendor/monarc/core MonarcCore;
ln -s ./../vendor/monarc/backoffice MonarcBO;
There is 2 parts:
* one only for front office
* one common for front office and back office (private project)
It is develop with zend framework 2
![Arbo](public/img/arbo2.png "Arbo")
Interfaces
----------
Repository for angular at project root:
mkdir node_modules
cd node_modules
git clone https://github.com/CASES-LU/ng-backoffice.git ng_backoffice
git clone https://github.com/CASES-LU/ng-anr.git ng_anr
There is 2 parts:
* one only for front office (ng_client)
* one common for front office and back office (private project) (ng_anr)
It is develop with angular framework version 1
![Arbo](public/img/arbo3.png "Arbo")
Web Server Setup
----------------
@ -63,7 +127,7 @@ project and you should be ready to go! It should look something like below:
Database connection
-------------------
Create file `config/autoload.local.php`:
Create file `config/autoload/local.php`:
return array(
'doctrine' => array(
@ -73,9 +137,74 @@ Create file `config/autoload.local.php`:
'host' => 'host',
'user' => 'user',
'password' => 'password',
'dbname' => 'monarc',
'dbname' => 'monarc_common',
),
),
'orm_cli' => array(
'params' => array(
'host' => 'host',
'user' => 'user',
'password' => 'password',
'dbname' => 'monarc_master',
),
),
),
),
);
Configuration
-------------
Create file configuration
sudo cp /config/autoload/local.php.dist /config/autoload/local.php
Update connexion information to local.php and global.php
Configuration files are stored in cache.
If yours changes have not been considered, empty cache by deleting file in /data/cache
Install Grunt
-------------
sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install -g grunt-cli
Only for linux system:
sudo ln -s /usr/bin/nodejs /usr/bin/node (seulement linux)
Update project
--------------
Play script (mandatory from the root of the project)(pull and migrations):
sudo /bin/bash ./scripts/update-all.sh
This shell script use others shell script. May be you node to change rights of these others files
Create Initial User and Client
------------------------------
Modify email and password (firstname or lastname) of first user in /module/MonarcBO/migrations/seeds/adminUserInit.php
If you have a mail server, you can keep default password and click on "Password forgotten ?" after user creation.
Create first user:
php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/MonarcBO/migrations/phinx.php
Data Model
----------
monarc_common
![monarc_common](public/img/model-common.png "monarc_common")
License
-------
This software is licensed under [GNU Affero General Public License version 3](http://www.gnu.org/licenses/agpl-3.0.html)
Copyright (C) 2016-2017 SMILE gie securitymadein.lu

View File

@ -3,9 +3,10 @@ author.name=Pascal Paulis
author.email=pascal.paulis@continuousphp.com
db.host=localhost
db.name=monarc
db.username=dbuser
db.password=123
db.name.core=monarc_core
db.name.backoffice=monarc_backoffice
dir.bin=./bin

View File

@ -32,34 +32,40 @@
</target>
<target name="setup-db" description="Setup Database Credentials">
<echo msg="Loading file ${project.basedir}/config/autoload/database.local.php.dist" />
<loadfile property="db.config" file="${project.basedir}/config/autoload/database.local.php.dist">
<filterchain>
<replacetokens>
<token key="db.host" value="${db.host}"/>
<token key="db.username" value="${db.username}"/>
<token key="db.password" value="${db.password}"/>
<token key="db.name" value="${db.name}"/>
<token key="db.name.backoffice" value="${db.name.backoffice}"/>
<token key="db.name.core" value="${db.name.core}"/>
</replacetokens>
</filterchain>
</loadfile>
<echo msg="Writing file ${project.basedir}/config/autoload/database.local.php" />
<echo message="${db.config}" file="${project.basedir}/config/autoload/database.local.php"/>
</target>
<target name="setup-languages" description="Setup Languages">
<echo msg="Loading file ${project.basedir}/config/autoload/languages.local.php.dist" />
<loadfile property="languages.config" file="${project.basedir}/config/autoload/languages.local.php.dist">
<!-- PLACE YOUR FILE MODIFICATIONS HERE -->
</loadfile>
<echo msg="Writing file ${project.basedir}/config/autoload/languages.local.php" />
<echo message="${languages.config}" file="${project.basedir}/config/autoload/languages.local.php"/>
</target>
<target name="setup-application" description="Setup Application config">
<loadfile property="app.config" file="${project.basedir}/config/application.config.php-dist-BO">
<loadfile property="app.config" file="/config/application.config.php">
<!-- PLACE YOUR FILE MODIFICATIONS HERE -->
</loadfile>
<echo message="${app.config}" file="${project.basedir}/config/application.config.php"/>
</target>
<target name="setup-sec-auth" description="Setup Security and Authentication">
<echo msg="Loading file ${project.basedir}/config/autoload/security-authentication.local.php.dist" />
<loadfile property="sec.config" file="${project.basedir}/config/autoload/security-authentication.local.php.dist">
<filterchain>
<replacetokens>
@ -68,6 +74,7 @@
</replacetokens>
</filterchain>
</loadfile>
<echo msg="Writing file ${project.basedir}/config/autoload/security-authentication.local.php" />
<echo message="${sec.config}" file="${project.basedir}/config/autoload/security-authentication.local.php"/>
</target>
@ -97,8 +104,8 @@
</target>
<target name="db-migration" description="Update the database version">
<exec command="${project.basedir}/scripts/client-upgrade-db.sh backoffice ${db.host} ${db.username} ${db.password} ${db.name}" passthru="true"/>
<exec command="${project.basedir}/scripts/client-upgrade-db.sh core ${db.host} ${db.username} ${db.password} ${db.name}" passthru="true"/>
<exec command="${project.basedir}/scripts/client-upgrade-db.sh backoffice ${db.host} ${db.username} ${db.password} ${db.name.backoffice}" passthru="true"/>
<exec command="${project.basedir}/scripts/client-upgrade-db.sh core ${db.host} ${db.username} ${db.password} ${db.name.core}" passthru="true"/>
</target>
<target name="reset-db"
@ -107,5 +114,5 @@
<target name="init"
description="Setup external dependencies and migrate data"
depends="setup-db, db-migration"/>
depends="setup-languages, setup-sec-auth, setup-db, db-migration"/>
</project>

View File

@ -13,8 +13,8 @@
"zendframework/zendframework": "2.5.3",
"doctrine/doctrine-orm-module": "^0.10",
"robmorgan/phinx": "0.5.*",
"monarc/core": "dev-master",
"monarc/backoffice": "dev-master",
"monarc/core": "dev-beta",
"monarc/backoffice": "dev-beta",
"phing/phing": "~2.0"
},
"config": {
@ -23,11 +23,11 @@
"repositories": [
{
"type": "vcs",
"url": "git+ssh://gogs@rhea.netlor.fr:2222/monarc/zm_core"
"url": "https://github.com/CASES-LU/zm-core"
},
{
"type": "vcs",
"url": "git+ssh://gogs@rhea.netlor.fr:2222/monarc/zm_backoffice"
"url": "https://github.com/CASES-LU/zm-backoffice"
}
]
}

6835
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -5,6 +5,7 @@
*
* @see https://github.com/zendframework/ZFTool
*/
$env = getenv('APP_ENV') ?: 'production';
return array(
'modules' => array(
'DoctrineModule',
@ -19,6 +20,12 @@ return array(
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php'
)
),
'config_cache_enabled' => ($env == 'production'),
'config_cache_key' => 'c8aaaaa11586f8b1bf5565cc6064e70a', // md5('config_cache_key_monarc')
'module_map_cache_enabled' => ($env == 'production'),
'module_map_cache_key' => '664579376c4dcdcaa0bcdd0f7e7bf25b', // md5('module_map_cache_key_monarc'),
'cache_dir' => 'data/cache/',
'check_dependencies' => ($env != 'production'),
),
);

View File

@ -1,24 +0,0 @@
<?php
/**
* Configuration file generated by ZFTool
* The previous configuration file is stored in application.config.old
*
* @see https://github.com/zendframework/ZFTool
*/
return array(
'modules' => array(
'DoctrineModule',
'DoctrineORMModule',
'MonarcCore',
'MonarcFO',
),
'module_listener_options' => array(
'module_paths' => array(
'./module',
'./vendor'
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php'
)
),
);

View File

@ -1,2 +1,4 @@
local.php
*.local.php
global.php
*.global.php

View File

@ -1,10 +0,0 @@
<?php
return [
'languages' => [
1 => 'Français',
2 => 'English',
3 => 'Deutsch'
],
'defaultLanguageIndex' => 2
];

View File

@ -1,24 +0,0 @@
<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'params' => array(
'host' => '@db.host@',
'user' => '@db.username@',
'password' => '@db.password@',
'dbname' => '@db.name@',
)
),
'orm_cli' => array(
'params' => array(
'host' => '@db.host@',
'user' => '@db.username@',
'password' => '@db.password@',
'dbname' => '@db.name@',
)
)
)
)
);

34
config/autoload/global.php Normal file → Executable file
View File

@ -12,18 +12,26 @@
*/
return array(
// DOCTRINE CONF
'service_manager' => array(
'factories' => array(
'doctrine.cache.mycache' => 'MonarcCore\Service\DoctrineCacheServiceFactory',
'doctrine.monarc_logger' => 'MonarcCore\Service\DoctrineLoggerFactory',
),
),
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'user',
'password' => 'password',
'user' => 'root',
'password' => '',
'dbname' => 'monarc_common',
'charset' => 'utf8',
'driverOptions' => array(
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
),
),
@ -31,13 +39,15 @@ return array(
'orm_cli' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'root',
'password' => 'password',
'password' => '',
'dbname' => 'monarc_cli',
'charset' => 'utf8',
'driverOptions' => array(
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
),
),
@ -71,9 +81,9 @@ return array(
),
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'metadata_cache' => 'mycache',
'query_cache' => 'mycache',
'result_cache' => 'mycache',
'driver' => 'orm_default', // This driver will be defined later
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
@ -83,11 +93,12 @@ return array(
'string_functions' => array(),
'numeric_functions' => array(),
'second_level_cache' => array(),
'sql_logger' => 'doctrine.monarc_logger',
),
'orm_cli' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'metadata_cache' => 'mycache',
'query_cache' => 'mycache',
'result_cache' => 'mycache',
'driver' => 'orm_cli', // This driver will be defined later
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
@ -97,6 +108,7 @@ return array(
'string_functions' => array(),
'numeric_functions' => array(),
'second_level_cache' => array(),
'sql_logger' => 'doctrine.monarc_logger',
),
),
),

109
config/autoload/global.php.dist Executable file
View File

@ -0,0 +1,109 @@
<?php
/**
* Global Configuration Override
*
* You can use this file for overriding configuration values from modules, etc.
* You would place values in here that are agnostic to the environment and not
* sensitive to security.
*
* @NOTE: In practice, this file will typically be INCLUDED in your source
* control, so do not include passwords or other sensitive information in this
* file.
*/
return array(
// DOCTRINE CONF
'service_manager' => array(
'factories' => array(
'doctrine.cache.mycache' => 'MonarcCore\Service\DoctrineCacheServiceFactory',
),
),
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => 3306,
'user' => 'user',
'password' => '',
'dbname' => 'monarc_common',
'charset' => 'utf8',
'driverOptions' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
),
),
),
'orm_cli' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => 3306,
'user' => 'root',
'password' => '',
'dbname' => 'monarc_cli',
'charset' => 'utf8',
'driverOptions' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
),
),
),
),
/*'migrations_configuration' => array(
'orm_default' => array(
'name' => 'Monarc Migrations',
'directory' => __DIR__."/../../migrations",
'namespace' => 'Monarc\Migrations',
'table' => 'migrations',
'column' => 'version',
),
'orm_cli' => array(
'name' => 'Monarc Common Migrations',
'directory' => __DIR__."/../../migrations",
'namespace' => 'MonarcCli\Migrations',
'table' => 'migrations',
'column' => 'version',
),
),*/
'entitymanager' => array(
'orm_default' => array(
'connection' => 'orm_default',
'configuration' => 'orm_default'
),
'orm_cli' => array(
'connection' => 'orm_cli',
'configuration' => 'orm_cli',
),
),
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'mycache',
'query_cache' => 'mycache',
'result_cache' => 'mycache',
'driver' => 'orm_default', // This driver will be defined later
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
'proxy_namespace' => 'DoctrineORMModule\Proxy',
'filters' => array(),
'datetime_functions' => array(),
'string_functions' => array(),
'numeric_functions' => array(),
'second_level_cache' => array(),
),
'orm_cli' => array(
'metadata_cache' => 'mycache',
'query_cache' => 'mycache',
'result_cache' => 'mycache',
'driver' => 'orm_cli', // This driver will be defined later
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
'proxy_namespace' => 'DoctrineORMModule\Proxy',
'filters' => array(),
'datetime_functions' => array(),
'string_functions' => array(),
'numeric_functions' => array(),
'second_level_cache' => array(),
),
),
),
// END DOCTRINE CONF
);

View File

@ -1,30 +0,0 @@
<?php
return array(
'languages' => [
1 => 'Français',
2 => 'English',
3 => 'Deutsch'
],
'defaultLanguageIndex' => 1,
/* Link with (ModuleCore)
config['languages'] = [
'fr' => array(
'index' => 1,
'label' => 'Français'
),
'en' => array(
'index' => 2,
'label' => 'English'
),
'de' => array(
'index' => 3,
'label' => 'Deutsch'
),
]
*/
'activeLanguages' => array('fr','en','de',)
);

View File

@ -33,15 +33,6 @@ return array(
),
),
'languages' => [
1 => 'Français',
2 => 'English',
3 => 'Deutsch'
],
'defaultLanguageIndex' => 1,
/* Link with (ModuleCore)
config['languages'] = [
'fr' => array(

View File

@ -1,13 +0,0 @@
<?php
return [
'smtp' => [
'name' => 'mailtrap.io',
'host' => 'mailtrap.io',
'connection_class' => 'crammd5',
'connection_config' => [
'username' => '******',
'password' => '******',
],
]
];

View File

@ -1,5 +1,6 @@
# continuous.yml
deployment:
hooks:
AfterInstall:
- command: scripts/migrate.sh
AfterActivate:
- command: scripts/migrate.sh
- command: scripts/restart-server.sh

View File

@ -10,8 +10,8 @@
"author": "Netlor",
"license": "Copyright",
"dependencies": {
"ng_anr": "git+ssh://gogs@rhea.netlor.fr:2222/monarc/ng_anr#master",
"ng_backoffice": "git+ssh://gogs@rhea.netlor.fr:2222/monarc/ng_backoffice#master"
"ng_anr": "https://github.com/CASES-LU/ng-anr#beta",
"ng_backoffice": "https://github.com/CASES-LU/ng-backoffice#beta"
},
"devDependencies": {
"grunt": "~0.4.1",

BIN
public/img/arbo1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
public/img/arbo2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
public/img/arbo3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
public/img/model-common.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -1,13 +1,27 @@
#!/bin/bash
if [ -d node_modules/ng_backoffice ]; then
pushd node_modules/ng_backoffice
grunt compile_translations
grunt concat
pushd node_modules/ng_backoffice
grunt compile_translations
grunt concat
if [ -d po ]; then
for i in $(ls po/*\.po); do
l=$(basename $i .po)
msgfmt -o ./po/$l.mo -v ./po/$l.po
done;
fi
fi
if [ -d node_modules/ng_client ]; then
pushd node_modules/ng_client
grunt compile_translations
grunt concat
pushd node_modules/ng_client
grunt compile_translations
grunt concat
if [ -d po ]; then
for i in $(ls po/*\.po); do
l=$(basename $i .po)
msgfmt -o ./po/$l.mo -v ./po/$l.po
done;
fi
fi

3
scripts/restart-server.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
service apache2 restart > /dev/null 2>&1 &
service php7.0-fpm restart > /dev/null 2>&1 &

View File

@ -66,3 +66,11 @@ fi
./scripts/link_modules_resources.sh
./scripts/compile_translations.sh
# Clear doctrine cache
php ./public/index.php orm:clear-cache:metadata
php ./public/index.php orm:clear-cache:query
php ./public/index.php orm:clear-cache:result
# Clear ZF2 cache
touch ./data/cache/upgrade && chmod 777 ./data/cache/upgrade