Set php command path automatically in the .bashrc file

ben shared this idea 1 year ago
Open Discussion

Hello,

A minor yet highly beneficial feature.

When dealing with PHP, the commands often require full paths like:

bash
#PHP
/opt/remi/php81/root/usr/bin/phpartisan cache:clear
#COMPOSER
/opt/remi/php81/root/usr/bin/php /usr/local/bin/composer install


These paths are cumbersome and not easy to recall. To simplify this, your support proposes incorporating the following alias in the .bashrc of every account(when php 8.1 is used for example):

bash
alias php="/opt/remi/php81/root/usr/bin/php"


This enables executing commands without specifying paths, such as(much easier):

bash
php artisan [command]


A valuable addition would be a checkbox next to the PHP selection in the User account of Spanel, labeled "Set as PHP command path."

This checkbox could automate the alias creation process(much faster).

This feature would be really cool to have.

Thank you!

0 votes

Comments (2)

photo

Hi Ben. SPanel has all the PHP versions binaries symlinked under /usr/bin on the server so you can easily call them from the command line like php81, php82, php74 etc.

# php81 -v

PHP 8.1.25 (cli) (built: Oct 24 2023 21:51:16) (NTS gcc x86_64)

Copyright (c) The PHP Group

Zend Engine v4.1.25, Copyright (c) Zend Technologies

    with the ionCube PHP Loader v13.0.2, Copyright (c) 2002-2023, by ionCube Ltd.

    with Zend OPcache v8.1.25, Copyright (c), by Zend Technologies

photo

Thank you so much Vlad!

Leave a Comment