Installing composer globally

Questions and mods regarding system management may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.
j.xavier.atero
Trainee
Trainee
Posts: 18
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Installing composer globally

Postby j.xavier.atero » Wed Sep 20, 2017 5:00 pm

Adding this entry just as a reference ...

To insall composer globally:

Code: Select all

sudo -i
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
exit

    :!: If no root access the following error message will be displayed: The installation directory "/usr/local/bin" is not writable
Last edited by j.xavier.atero on Fri Dec 08, 2017 12:07 am, edited 6 times in total.
j.xavier.atero
Trainee
Trainee
Posts: 18
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Installing composer globally

Postby j.xavier.atero » Wed Sep 20, 2017 5:58 pm

When executing composer using php56 command it might be necessary to specify the absolute route:

Code: Select all

php56 /usr/local/bin/composer

    :!: otherwise the following error message might be displayed: Could not open input file: composer
j.xavier.atero
Trainee
Trainee
Posts: 18
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Installing composer globally

Postby j.xavier.atero » Fri Dec 08, 2017 12:34 am

PHP version 7.0 might be required for some packages installation. A message similar to the following one might be displayed:

[InvalidArgumentException]
Could not find package ... with stability stable in a version installable using your PHP version 5.6.31.


To install packages requiring PHP 7.0 follow these steps:

1- Install PHP 7.0

    :idea: Path to the files:
    - php70: /var/packages/PHP7.0/target/usr/local/bin/php70
    - php.ini: /usr/local/etc/php70
    - symlink to php70: /usr/local/bin/php70

    Code: Select all

    $ php70 --ini
    Configuration File (php.ini) Path: /usr/local/etc/php70
    Loaded Configuration File:         /usr/local/etc/php70/php.ini
    Scan for additional .ini files in: /usr/local/etc/php70/conf.d
    Additional .ini files parsed:      (none)


2- Add required extensions:
Edit php.ini file

Code: Select all

sudo vi /usr/local/etc/php70/php.ini

Add extensions

Code: Select all

[PHP]
...
extension = phar.so
extension = openssl.so
extension = zip.so


    :!: Adding extensions through Main Menu > Web Station > PHP Settings will not make them available to the CLI, only to the Web Station

    :!: If phar extension not enabled, the following error message will be displayed:
    PHP Fatal error: Uncaught Error: Class 'Phar' not found in /usr/local/bin/composer:23
    Stack trace:
    #0 {main}
    thrown in /usr/local/bin/composer on line 23


    :!: If openssl extension not enabled, the following error message will be displayed:
    [Composer\Exception\NoSslException]
    The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-
    tls' option to true.


    :!: If zip extension not enabled, the following error message will be displayed: ... Failed to download ... from ...: The zip extension and unzip command are both missing, skipping.

3- Run composer:

Code: Select all

cd path_to_my_folder
php70 /usr/local/bin/composer


There are other possible options:
- Use the -d flag to load the extensions when executing composer
- Change the default php version of the DSM CLI. Default php system files:

    Code: Select all

    $ php --ini
    Configuration File (php.ini) Path: /etc/php
    Loaded Configuration File:         /etc/php/php.ini
    Scan for additional .ini files in: (none)
    Additional .ini files parsed:      (none)

j.xavier.atero
Trainee
Trainee
Posts: 18
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Installing composer globally

Postby j.xavier.atero » Sat Dec 09, 2017 2:35 pm

For packages requiring PHP 7.1 follow the installation steps from this post: https://forum.synology.com/enu/viewtopic.php?t=135769

To run composer with Entware PHP 7.1:

Code: Select all

cd path_to_my_folder
php-cli /usr/local/bin/composer

Return to “System Managment Mods”

Who is online

Users browsing this forum: No registered users and 3 guests