When using theme in WordPress, getting an error like the following:
[05-Dec-2021 21:11:48 UTC] PHP Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) in /home/***/public_html/wp-content/themes/stockholm/framework/admin/options/elements/map.php on line 71
Solution
In Hebrew ‘PAAMAYIM NEKUDOTAYIM’ means double colons. PHP has stopped using a double colon to refer to object elements. These need to use the ‘->’ arrow instead of the ‘::’ double colon. In our case, the issue was with the following:
When we try to run a composer command, like update, we usually do the following:
composer update
Cpanel has multiple PHP binaries, but in this case, we are unable to select a specific PHP binary to use, instead we have to run it with the default one, how to run composer update with a different php binary in cpanel?
Solution
composer binary file, is a phar file. PHAR is necessarily a PHP Archive and usually automatically detect the running php. But as it is essentially written in php, you may explicitly run it with a different php binary, if you want. To run composer with different php binary, first, you need to find the location of composer. You may do so, using the following:
root@mirage [~]# which composer
/opt/cpanel/composer/bin/composer
Cpanel different php binaries are available under the following kind of directory:
/opt/cpanel/ea-phpXX/usr/bin/php
XX is the version number of PHP. So for example if you need to use PHP 7.4, you would need to run using the following:
/opt/cpanel/ea-php74/usr/bin/php
Now, to run composer update along with PHP 7.4 binary, you may do something like the following:
First, make sure you are in the directory where you want to install laravel, for example, something like the following:
cd /home/username/public_html
Then, you may run the above command:
/opt/cpanel/ea-php74/usr/bin/php /opt/cpanel/composer/bin/composer update
or in case, you want to to install
/opt/cpanel/ea-php74/usr/bin/php /opt/cpanel/composer/bin/composer install
or may be, you wan to run update with no-scripts
/opt/cpanel/ea-php74/usr/bin/php /opt/cpanel/composer/bin/composer update --no-scripts
There are couple of ways you can run composer with Plesk Shell. My favorite one is to add php to your PATH variable, and it will automatically add the composer as well. You may follow through the following to modify your shell path variable to use Plesk PHP:
Once done, now you may run composer command and it shall work:
Your binary to php is probably being used through redirection like .bashrc file and an alias is hooked for your php command to work. A better way to do this, is to hook the php binary to your PATH variable. You may do this and fix the error by following this tutorial:
If you have added SSH access to your plesk user using the following tutorial:
and then, tried to run php command like the following:
[elastic-keldysh@pl1 ~]$ php -v
-bash: php: command not found
You might have encountered the above error. This is because plesk do not store the php binary in your PATH variable locations. You may check your existing path variables here:
Plesk stores it’s php binaries for different versions here:
/opt/plesk/php/
So, for example if you are trying to use PHP 7.4 binary, this would be like the following:
[elastic-keldysh@pl1 php]$ /opt/plesk/php/7.4/bin/php -v
PHP 7.4.10 (cli) (built: Sep 4 2020 03:49:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with the ionCube PHP Loader + ionCube24 v10.4.2, Copyright (c) 2002-2020, by ionCube Ltd.
with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies
So, to use only php -v, you need to add this bin path to your path variable. You may do that by running the following command:
PATH=$PATH:/opt/plesk/php/7.4/bin/
Now, you may run the following and it will work:
[elastic-keldysh@pl1 php]$ php -v
PHP 7.4.10 (cli) (built: Sep 4 2020 03:49:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with the ionCube PHP Loader + ionCube24 v10.4.2, Copyright (c) 2002-2020, by ionCube Ltd.
with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies
Now, we need to remember, this will only sustain for the existing session, if we log out and re login, this would be lost. To keep this permanent on each login, we need to put this in the .profile file. You may do this by running the following:
A common error I have seen users reporting using Laravel, is the following:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
The error actually happens because Laravel 5.5 assumes you have MySQL 5.7.7 or above. While on MySQL 5.7.7 the key size was increased than the older versions.
How to fix laravel Specified key was too long
To fix this, find the AppServiceProvider.php file under app/Providers folder, and add the following line before start of the class:
use Illuminate\Support\Facades\Schema;
Then, inside the boot() method under the class, add the following line:
Schema::defaultStringLength(191);
If you restart your laravel migration or the query, it should work fine now.