Skip to content
Yurii Torbyk edited this page Jan 8, 2019 · 5 revisions

Sage installs PHP 5.6, 7.0, 7.1, 7.2, 7.3 versions and can:

  • switch php versions
  • enable/disable xDebug extension
  • enable/disable ionCube extension
  • catch and save all emails sent by mail php function

PHP installation and its leveraging use next configuration section:

    'php' => [
        'main_version' => '7.3',
        'brew_path' => '/usr/local/bin/php',
        'brew_etc_path' => '/usr/local/etc/php',
        'brew_lib_path' => '/usr/local/lib/php',
        'brew_pear_path' => '/usr/local/share/pear',
        'taps' => [
            '7.0' => 'samgranger/php'
        ],
        'versions' => [
            '5.6',
            '7.0',
            '7.1',
            '7.2',
            '7.3'
        ],
        'mail_path' => '/Users/username/xSage/mail',
        'smtp_catcher_path' => '/Users/username/.sage/smtp_catcher.php'
    ]

Installation

Installation can be triggered by sage php:install command or as a step in sage env:install command.

PHP installation actions for each version (see ['php']['versions'])

  • install Brew formula php@*
  • add z-performance.ini config from template, it overwrites default settings soe Sage doesn't change origin php.ini
  • update opcache config from template (origin config backed up)
  • install xDebug via Pecl and disable
  • install ionCube and disable

Uninstallation

In order to uninstall PHP run sage php:uninstall command or sage env: uninstall command then all PHP version will be deleted with all other sage's environment.

PHP uninstallation actions:

  • uninstall all php@* Brew formulas (see ['php']['versions'])
  • delete ionCube extension
  • delete xDebug Pecl extension
  • delete php and pear config directories (see ['php']['brew_etc_path'], ['php']['brew_lib_path'] and ['php']['brew_pear_path'])

Email catcher

Sage sets to sendmail_path config path to /Users/username/.sage/smtp_catcher.php script (see ['php']['smtp_catcher_path']).

The script catches emails sent by mail php function and saves them into /Users/username/xSage/mail directory as *.eml files so they could be open by Mail app.

Switch versions

Sage can unlink/link Brew's php formulas so you can have any php version you currently need.

In order to find out which is current version, run php -v command in terminal.

In order to switch PHP version run sage php:switch [version] command.

The command doesn't have required arguments, so when you run it you will be prompted to choose which version you want to switch on.

After switching php version Sage will restart Apache. However if you don't need it, you can pass --skip or -s flag.

# switch php on 7.1 and restart Apache
sage php:switch 7.1

# switch php on 7.2 without restarting of Apache
sage php:switch 7.2 -s

xDebug toggle

Sage can enable or disable xDebug extension for current php version.

In order to do it run command sage php:xdebug [on|off].

The command doesn't have required arguments, so when you run it Sage determines if xDebug enabled and you will be prompted to confirm opposite action or cancel the command.

If you need to enable xDebug with remote autostart setting enable you can pass --remote-autostart or -a flag. Pay attention that:

  • if you already enable xDebug and need to add remote autostart settings you need to disable it first and enable with the flag
  • each time when you disable xDebug the flag is set to no

After toggling xDebug Sage will restart Apache. However if you don't need it, you can pass --skip or -s flag.

#enable `xDebug` with remote autostart and without restarting of Apache
sage php:xdebug on -a -s

#disalbe `xDebug` and restart Apache
sage php:xdebug off

ionCube toggle

Sage can enable or disable ionCube extension for current php version.

In order to do it run command sage php:ioncube [on|off].

The command doesn't have required arguments, so when you run it Sage determines if ionCube enabled and you will be prompted to confirm opposite action or cancel the command.

After toggling ionCube Sage will restart Apache. However if you don't need it, you can pass --skip or -s flag.

#enable `ionCube` without restarting of Apache
sage php:ioncube on -s

#disalbe `ionCube` and restart Apache
sage php:ioncube off