PHP setup for command line usage

PHP is required for command line or REST client use only

A. PHP check

FolderShare command line client requires PHP, check if your system already has PHP7.2.x+ installed

  1. Linux: Few Linux distributions ship with PHP, if not available see section B3
  2. Mac OS: Recent versions of Mac OS already have PHP7.2+ installed
  3. Windows: PHP needs to be installed, see section B1

Check php availability on your computer as follows

# On terminal issue the following command
php -v

B. Installing PHP 7.2.x+

1 Windows 

Follow instructions noted here 

  1. Download PHP 7.2.28
  2. Unzip and rename the folder to PHP
  3. Move PHP folder to C:/
  4. Add new Environment Variables for PHP
  5. Restart computer
  6. Test PHP on terminal/command prompt

2 Mac OS

Recent versions of Mac OS already ship with php7.2.x+


3 Linux

See instructions below to install php with root privileges or building it from source as a regular user.

i Install with root privileges 

On Debian/Ubuntu see article here

# Only the following items are needed for foldershare client
apt-get install php7.2-cli php7.2-curl php7.2-mbstring

On CentOS

yum -y install centos-release-scl.noarch
yum search php72-
yum install rh-php72-php-cli.x86_64
yum install rh-php72-php-mbstring.x86_64

ii Building minimal PHP from source

Download latest PHP7.2.x then unzip and build as follows 

# Fetch php7.2.28 source
curl -o php-7.2.28.tar.gz -L http://php.net/get/php-7.2.28.tar.gz/from/this/mirror

# untar php source
tar xzf php-7.2.28.tar.gz

cd php-7.2.28

# Configure minimal build necessary for the FolderShare client
# Optionally add --prefix=/path/to/install
./configure --disable-all --disable-cgi --enable-cli --enable-filter --enable-json --enable-mbstring --with-curl --with-readline 

# build
make
# make install #if you added prefix

# Add environment path to find php
export PATH=`pwd`/sapi/cli:$PATH" #change this path if you added prefix

# Check if php is now in environment path
php -v

# Consider adding the php path in your shell profile (e.g. basic)

iii Add environment path

After installing PHP, add php to your environment path for e.g. append the following to your ~/.bashrc

export PATH="/full/path/to/php:$PATH"