DEV Community

nabbisen
nabbisen

Posted on

Almost PHP 7.2 Composer With OpenBSD 6.4

PHP composer is a popular dependency/package manager.
OpenBSD 6.4 provides the package of its 1.6.3 version.
How to install it:

# pkg_add composer
Enter fullscreen mode Exit fullscreen mode

It's, however, based on PHP 7.0 whose support has come to an end.
It seems partially because:

not 7.2 yet as some things are still using mcrypt

Of course, the situation has been being improved by the great developers.


Well, there might be some cases that using PHP greater than 7.0 is required (or just wanted) because of security issues, PHP extensions, dependencies or something else.
EC-CUBE, a Japanese eCommerce/cart system, is the case to me.

I found the way by using composer.phar:

# php-7.2 /usr/local/libexec/composer.phar [subcommands] ...
Enter fullscreen mode Exit fullscreen mode

For example, installing EC-CUBE in my case is available with this command:

$ php-7.2 /usr/local/libexec/composer.phar create-project ec-cube/ec-cube ./ec-cube "4.0.x-dev" --keep-vcs
Enter fullscreen mode Exit fullscreen mode

* Caution: composer is recommended to be run in user mode.


Additionally, the path to php is sometimes required through the execution.
The solution is to create a symbolic link:

# ln -s /usr/local/bin/php-7.2 /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

Now you can use php commands:

$ php /usr/local/libexec/composer.phar [subcommands] ...
Enter fullscreen mode Exit fullscreen mode

Remove the link after using it as needed:

# rm /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

Besides, platform config of composer like this might be sometimes helpful:

$ composer config platform.php 7.2.10
$ # or
$ composer config --global platform.php 7.2.10
Enter fullscreen mode Exit fullscreen mode

Happy coding.

Top comments (0)