Difference between revisions of "Composer and NPM"
Bradymiller (talk | contribs) |
|||
(151 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
=Overview= | =Overview= | ||
==Introduction== | ==Introduction== | ||
Composer | :'''Composer''' provides the following key functions for OpenEMR: | ||
:# A tool for dependency management of packages for OpenEMR in 'vendor' directory. | |||
:# An autoloader of libraries including OpenEMR classes. | |||
:'''NPM''' provide the following key functions for OpenEMR: | |||
:# | :# A tool for dependency management of packages for OpenEMR in 'public/assets' directory. | ||
:# | :# A tool for building css theme files for OpenEMR in 'public/themes' directory. | ||
:# A open door to do lots of cool stuff in the future. | |||
:# | |||
=Installation= | =Installation= | ||
==Windows== | ==Composer== | ||
===Windows=== | |||
This is the easiest way to get Composer set up on your machine. | This is the easiest way to get Composer set up on your machine. | ||
Line 52: | Line 46: | ||
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</pre> | -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</pre> | ||
==Linux & MacOS== | ===Linux & MacOS=== | ||
The first step is to download Composer, which will effectively create a Phar (PHP Archive) file called composer.phar. From your terminal, run the following command: | The first step is to download Composer, which will effectively create a Phar (PHP Archive) file called composer.phar. From your terminal, run the following command: | ||
<pre>curl -sS https://getcomposer.org/installer | php</pre> | <pre>curl -sS https://getcomposer.org/installer | php</pre> | ||
Line 91: | Line 85: | ||
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. | -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. | ||
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</pre> | -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug</pre> | ||
==NPM== | |||
:Instructions are under construction. | |||
=Usage= | =Usage= | ||
Line 98: | Line 95: | ||
<pre>cd openemr | <pre>cd openemr | ||
git checkout master</pre> | git checkout master</pre> | ||
To run Composer for the first time and install | To run Composer for the first time and install the packages simply run: | ||
<pre>composer install</pre> | <pre>composer install</pre> | ||
When Composer has finished its install you’ll be ready to install OpenEMR. | When Composer has finished its install you’ll be ready to install OpenEMR after you run the following commands to bring in npm packages and build css scripts and optimize composer autoloading: | ||
<pre>npm install | |||
npm run build | |||
composer dump-autoload -o</pre> | |||
=Dependencies= | |||
==Composer== | |||
===Always included=== | |||
#adldap2/adldap2 (REMOVED in OpenEMR 5.0.3+) | |||
#adodb/adodb-php | |||
#doctrine/common | |||
#doctrine/couchdb | |||
#doctrine/orm | |||
#dompdf/dompdf | |||
#ezyang/htmlpurifier (Sherwin plans to use to html escape editors that need to allow html code) | |||
#knplabs/knp-snappy | |||
#mobiledetect/mobiledetectlib (Ray is using this for an ongoing project that should get into codebase into the future) | |||
#mpdf/mpdf | |||
#phpmailer/phpmailer | |||
#phpoffice/phpspreadsheet (Sherwin plans to use this; note Kim was planning to use a prior deprecated package phpoffice/phpexcel for allscripts rx module and will instead need to use phpspreadsheet now) | |||
#phpseclib/phpseclib | |||
#rospdf/pdf-php | |||
#smarty/smarty | |||
#stripe/stripe-php (Sherwin requested this for incorporating payment collection via stripe) | |||
#symfony/config | |||
#symfony/dependency-injection | |||
#symfony/event-dispatcher | |||
#symfony/http-foundation | |||
#symfony/yaml | |||
#twig/twig | |||
#vlucas/phpdotenv | |||
#zendframework/zendframework | |||
===Optional=== | |||
#openemr/wkhtmltopdf-openemr - Used by institutional billing (ub04) to create the pdf's. Very large (240MB) so unable to include in main codebase. Install via following command in the openemr directory: | |||
#*composer require openemr/wkhtmltopdf-openemr | |||
===Global=== | |||
:This section is for developers, and these are packages that should be installed globally: | |||
#phing/phing (this is used by mechanism for cleaning out stuff when bring in new composer/npm packages) | |||
===Work in Progress=== | |||
#html2pdf - spipu/html2pdf (also need to include setasign/fpdi-tcpdf) (PENDING REMOVAL - migrating to mPDF) | |||
#TCPDF - tecnickcom/tcpdf (PENDING REMOVAL - migrating to mPDF) | |||
#FPDF - setasign/fpdf (UNABLE to do this since there is a needed minor modification to work with PDF_Label; there is no way around this since certain variables are set as protected and the prior version of FPDF that would work is not compatible with PHP7)(only plan to use FPDF for PDF_Label anyways, so not a huge deal)(is stored at library/classes/fpdf) | |||
#FPDI - setasign/fpdi (COMPLETED; this was brought in by mPDF; will try to remove other copy when get rid of html2pdf/TCPDF stuff) | |||
==NPM== | |||
===Always included=== | |||
#AnythingSlider-1-9-4 | |||
#angular-1-5-8 | |||
#angular-sanitize-1-5-8 | |||
#angular-summernote-0-8-1 | |||
#backbone-1-3-3 | |||
#bootstrap-3-3-4 | |||
#bootstrap-rtl-3-3-4 | |||
#Chart.js-2-1-3 | |||
#checklist-model-0-10-0 | |||
#ckeditor-4-11-1 | |||
#datatables.net-1-10-13 | |||
#datatables.net-bs-1-10-13 | |||
#*This is the bootstrap styling for datatables-1-10-13. | |||
#datatables.net-dt-1-10-13 | |||
#*This is the generic styling for datatables-1-10-13. | |||
#datatables.net-jqui-1-10-13 | |||
#*This is the jquery-ui styling for datatables-1-10-13. | |||
#datatables.net-colreorder-1-3-2 | |||
#*This is an extension for datatables-1-10-13. | |||
#datatables.net-colreorder-dt-1-3-2 | |||
#*This is the generic styling for datatables.net-colreorder-dt-1-3-2. | |||
#datatables.net-scroller-1-4-2 | |||
#*This is an extension for datatables-1-10-13. | |||
#datatables.net-scroller-jqui-1-4-2 | |||
#*This is the jquery-ui styling for datatables.net-scroller-1-4-2. | |||
#dropzone-4-3-0 | |||
#dwv-0-21-0 | |||
#emodal-1-2-67 | |||
#flot-0-8-3 | |||
#font-awesome-4-6-3 | |||
#i18next-9-0-1 | |||
#i18next-browser-languagedetector-2-0-0 | |||
#i18next-xhr-backend-1-4-3 | |||
#jquery-creditcardvalidator-1-1-0 | |||
#jquery-datetimepicker-2-5-4 | |||
#*Use the files in build directory (and do NOT use build/jquery.datetimepicker.min.js) | |||
#jquery.gritter-1-7-4 | |||
#jquery-min-* | |||
#*Contain the jquery library files. This is brought in via bower by direct html download since the old versions are not available in repo (need to be built) and only 1 file is needed for these numerous different versions of jquery. | |||
#*jquery-min-1-10-2 is used by datatables.net-1-10-13 | |||
#jquery-panelslider-0-1-1 | |||
#jquery-ui-1-10-4 | |||
#jquery-ui-1-11-4 | |||
#jquery-ui-1-12-1 | |||
#jquery-validation-1-13-0 | |||
#jscolor-2-0-4 | |||
#jszip-3-1-5 | |||
#knockout-3-4-0 | |||
#konva-1-6-8 | |||
#literallycanvas-0-4-13 | |||
#magic-wand-js | |||
#modernizr-3-5-0 | |||
#:After collect via bower, need to do the following to create the dist/modernizr-build.js script: | |||
#:*cd public/assets/modernizr-3-5-0 | |||
#:*npm install | |||
#:*grunt build | |||
#:*rm -fr node_modules | |||
#moment-2-13-0 | |||
#numeral-1-5-3 (requested by Matrix, but not used yet) | |||
#pure-0-5-0 | |||
#qtip2-2-2-1 | |||
#qtip2-3-0-3 | |||
#react-15-1-0 | |||
#select2 | |||
#select2-bootstrap-theme | |||
#shortcut.js-2-01-B | |||
#*Not supported by bower, so brought in manually to the ''manual-added-packages'' sub-directory. | |||
#*In future, can likely bring this in via bower via http method. | |||
#summernote-0-8-2 | |||
#*Note this has a plugin system that is not supported by bower and need to manually copy in the plugins into the asset. Here are the plugin(s) that were placed manually: | |||
#:*The Nugget plugin was placed at summernote-0-8-2/dist/plugin/nugget/* | |||
#underscore-1-8-3 | |||
#undone.js-0-0-1 | |||
#validate.js-0-12-0 (requested by Matrix and Ray, but not used yet) | |||
=Adding new packages= | |||
==Composer== | |||
:# Add package/vendor to the composer.json file | |||
:# run <code>composer install</code> | |||
:##(if this isn't bringing in requested package, then will need to remove the composer.lock file before running the command) | |||
:# Remove unused files(if they are present) from the installed package (eg. git, .gitignore, tests, docs) - You must update build.xml to include directory(s). This step will require a composer global install of phing and then use the path to phing below in the call. | |||
:## Windows - From the command line run <code>call vendor/bin/phing vendor-clean</code> | |||
:## Linux - From the command line run <code>./vendor/bin/phing vendor-clean</code> | |||
:##*(btw, if need to clean up public/assets for [[Bower|bower stuff]], then run <code>./vendor/bin/phing assets-clean</code> ) | |||
:# run <code>composer dump-autoload -o</code> | |||
==NPM== | |||
:Instructions are under construction | |||
=Autoloader= | |||
==Ongoing Work== | |||
:Working on using the autoloader to modernize the OpenEMR codebase. Steps: | |||
:#Place the central libraries that are always called in OpenEMR into the autoloader. (COMPLETED) | |||
:#Place the OpenEMR classes into the classmap autoloader.(IN PROGRESS) | |||
:#*Done with library/classes with following exceptions that plan to work on: | |||
:#:*Prescription.class.php, /ClinicalTypes, /rulesets, and /smtp. | |||
:#Convert libraries into classes and also bring these in via the classmap autoloader. | |||
:#Above steps will allow then to do the following: | |||
:#*Remove globals from within classes. | |||
:#*Write phpunit tests. | |||
:#Place new "modernized" OpenEMR classes into the PSR-4 autoloader.(IN PROGRESS) | |||
==Update Autoloader== | |||
< | :If updating classes within OpenEMR to work with the autoloader, then just need to run the following command: | ||
:* run <code>composer dump-autoload -o</code> | |||
= | =Forum= | ||
:*[https://community.open-emr.org/t/composer/8001 Composer] | |||
Latest revision as of 00:58, 2 November 2019
Overview
Introduction
- Composer provides the following key functions for OpenEMR:
- A tool for dependency management of packages for OpenEMR in 'vendor' directory.
- An autoloader of libraries including OpenEMR classes.
- NPM provide the following key functions for OpenEMR:
- A tool for dependency management of packages for OpenEMR in 'public/assets' directory.
- A tool for building css theme files for OpenEMR in 'public/themes' directory.
- A open door to do lots of cool stuff in the future.
Installation
Composer
Windows
This is the easiest way to get Composer set up on your machine.
The installer will download composer for you and set up your PATH environment variable so you can simply call composer
from any directory.
Download and run Composer-Setup.exe - it will install the latest composer version whenever it is executed.
See: https://getcomposer.org/doc/00-intro.md/
To test your installation, open up your favourite Command Line Interface (CLI) and run:
composer
And you should get output similar to this:
______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.1.2 2016-05-31 19:48:11 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Linux & MacOS
The first step is to download Composer, which will effectively create a Phar (PHP Archive) file called composer.phar. From your terminal, run the following command:
curl -sS https://getcomposer.org/installer | php
The resulting file will be called composer.phar, a PHP Archive that can be executed directly via PHP. However, in our case, we want Composer to be accessible globally by simply typing composer
. To do this, move it to /usr/bin/ and create an alias:
sudo mv composer.phar /usr/local/bin/ vim ~/.bash_profile
Add this to your .bash_profile. It may be empty or non-existent, so go ahead and create it:
alias composer="php /usr/local/bin/composer.phar"
Now, relaunch your terminal and you'll be able to access Composer simply by calling composer
See: https://www.abeautifulsite.net/installing-composer-on-os-x
To test your installation, open up your favourite Command Line Interface (CLI) and run:
composer
And you should get output similar to this:
______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.1.2 2016-05-31 19:48:11 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
NPM
- Instructions are under construction.
Usage
- clone the OpenEMR development version from github: https://github.com/openemr/openemr.git
git clone https://github.com/openemr/openemr.git
- Once it’s done run the following command to move into the OpemEMR root directory and checkout the master branch.
cd openemr git checkout master
To run Composer for the first time and install the packages simply run:
composer install
When Composer has finished its install you’ll be ready to install OpenEMR after you run the following commands to bring in npm packages and build css scripts and optimize composer autoloading:
npm install npm run build composer dump-autoload -o
Dependencies
Composer
Always included
- adldap2/adldap2 (REMOVED in OpenEMR 5.0.3+)
- adodb/adodb-php
- doctrine/common
- doctrine/couchdb
- doctrine/orm
- dompdf/dompdf
- ezyang/htmlpurifier (Sherwin plans to use to html escape editors that need to allow html code)
- knplabs/knp-snappy
- mobiledetect/mobiledetectlib (Ray is using this for an ongoing project that should get into codebase into the future)
- mpdf/mpdf
- phpmailer/phpmailer
- phpoffice/phpspreadsheet (Sherwin plans to use this; note Kim was planning to use a prior deprecated package phpoffice/phpexcel for allscripts rx module and will instead need to use phpspreadsheet now)
- phpseclib/phpseclib
- rospdf/pdf-php
- smarty/smarty
- stripe/stripe-php (Sherwin requested this for incorporating payment collection via stripe)
- symfony/config
- symfony/dependency-injection
- symfony/event-dispatcher
- symfony/http-foundation
- symfony/yaml
- twig/twig
- vlucas/phpdotenv
- zendframework/zendframework
Optional
- openemr/wkhtmltopdf-openemr - Used by institutional billing (ub04) to create the pdf's. Very large (240MB) so unable to include in main codebase. Install via following command in the openemr directory:
- composer require openemr/wkhtmltopdf-openemr
Global
- This section is for developers, and these are packages that should be installed globally:
- phing/phing (this is used by mechanism for cleaning out stuff when bring in new composer/npm packages)
Work in Progress
- html2pdf - spipu/html2pdf (also need to include setasign/fpdi-tcpdf) (PENDING REMOVAL - migrating to mPDF)
- TCPDF - tecnickcom/tcpdf (PENDING REMOVAL - migrating to mPDF)
- FPDF - setasign/fpdf (UNABLE to do this since there is a needed minor modification to work with PDF_Label; there is no way around this since certain variables are set as protected and the prior version of FPDF that would work is not compatible with PHP7)(only plan to use FPDF for PDF_Label anyways, so not a huge deal)(is stored at library/classes/fpdf)
- FPDI - setasign/fpdi (COMPLETED; this was brought in by mPDF; will try to remove other copy when get rid of html2pdf/TCPDF stuff)
NPM
Always included
- AnythingSlider-1-9-4
- angular-1-5-8
- angular-sanitize-1-5-8
- angular-summernote-0-8-1
- backbone-1-3-3
- bootstrap-3-3-4
- bootstrap-rtl-3-3-4
- Chart.js-2-1-3
- checklist-model-0-10-0
- ckeditor-4-11-1
- datatables.net-1-10-13
- datatables.net-bs-1-10-13
- This is the bootstrap styling for datatables-1-10-13.
- datatables.net-dt-1-10-13
- This is the generic styling for datatables-1-10-13.
- datatables.net-jqui-1-10-13
- This is the jquery-ui styling for datatables-1-10-13.
- datatables.net-colreorder-1-3-2
- This is an extension for datatables-1-10-13.
- datatables.net-colreorder-dt-1-3-2
- This is the generic styling for datatables.net-colreorder-dt-1-3-2.
- datatables.net-scroller-1-4-2
- This is an extension for datatables-1-10-13.
- datatables.net-scroller-jqui-1-4-2
- This is the jquery-ui styling for datatables.net-scroller-1-4-2.
- dropzone-4-3-0
- dwv-0-21-0
- emodal-1-2-67
- flot-0-8-3
- font-awesome-4-6-3
- i18next-9-0-1
- i18next-browser-languagedetector-2-0-0
- i18next-xhr-backend-1-4-3
- jquery-creditcardvalidator-1-1-0
- jquery-datetimepicker-2-5-4
- Use the files in build directory (and do NOT use build/jquery.datetimepicker.min.js)
- jquery.gritter-1-7-4
- jquery-min-*
- Contain the jquery library files. This is brought in via bower by direct html download since the old versions are not available in repo (need to be built) and only 1 file is needed for these numerous different versions of jquery.
- jquery-min-1-10-2 is used by datatables.net-1-10-13
- jquery-panelslider-0-1-1
- jquery-ui-1-10-4
- jquery-ui-1-11-4
- jquery-ui-1-12-1
- jquery-validation-1-13-0
- jscolor-2-0-4
- jszip-3-1-5
- knockout-3-4-0
- konva-1-6-8
- literallycanvas-0-4-13
- magic-wand-js
- modernizr-3-5-0
- After collect via bower, need to do the following to create the dist/modernizr-build.js script:
- cd public/assets/modernizr-3-5-0
- npm install
- grunt build
- rm -fr node_modules
- After collect via bower, need to do the following to create the dist/modernizr-build.js script:
- moment-2-13-0
- numeral-1-5-3 (requested by Matrix, but not used yet)
- pure-0-5-0
- qtip2-2-2-1
- qtip2-3-0-3
- react-15-1-0
- select2
- select2-bootstrap-theme
- shortcut.js-2-01-B
- Not supported by bower, so brought in manually to the manual-added-packages sub-directory.
- In future, can likely bring this in via bower via http method.
- summernote-0-8-2
- Note this has a plugin system that is not supported by bower and need to manually copy in the plugins into the asset. Here are the plugin(s) that were placed manually:
- The Nugget plugin was placed at summernote-0-8-2/dist/plugin/nugget/*
- underscore-1-8-3
- undone.js-0-0-1
- validate.js-0-12-0 (requested by Matrix and Ray, but not used yet)
Adding new packages
Composer
- Add package/vendor to the composer.json file
- run
composer install
- (if this isn't bringing in requested package, then will need to remove the composer.lock file before running the command)
- Remove unused files(if they are present) from the installed package (eg. git, .gitignore, tests, docs) - You must update build.xml to include directory(s). This step will require a composer global install of phing and then use the path to phing below in the call.
- Windows - From the command line run
call vendor/bin/phing vendor-clean
- Linux - From the command line run
./vendor/bin/phing vendor-clean
- (btw, if need to clean up public/assets for bower stuff, then run
./vendor/bin/phing assets-clean
)
- (btw, if need to clean up public/assets for bower stuff, then run
- Windows - From the command line run
- run
composer dump-autoload -o
NPM
- Instructions are under construction
Autoloader
Ongoing Work
- Working on using the autoloader to modernize the OpenEMR codebase. Steps:
- Place the central libraries that are always called in OpenEMR into the autoloader. (COMPLETED)
- Place the OpenEMR classes into the classmap autoloader.(IN PROGRESS)
- Done with library/classes with following exceptions that plan to work on:
- Prescription.class.php, /ClinicalTypes, /rulesets, and /smtp.
- Convert libraries into classes and also bring these in via the classmap autoloader.
- Above steps will allow then to do the following:
- Remove globals from within classes.
- Write phpunit tests.
- Place new "modernized" OpenEMR classes into the PSR-4 autoloader.(IN PROGRESS)
Update Autoloader
- If updating classes within OpenEMR to work with the autoloader, then just need to run the following command:
- run
composer dump-autoload -o
- run