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:
I want to change the memory_limit of a virtual host in virtualmin. How can I do that?
Solution
First, login to Virtualmin on port 10000, now, select the virtual host from the dropdown under Virtualmin tab. Now under the services, there are PHP 5 Configuration and PHP 7 Configuration
Click on the version you want to change configuration for. It will show you a list of options to change php variables.
Now there is ‘Resource Limit’, that contains the options like maximum execution time, or memory limit for PHP.
Now, change the ‘Maximum Memory Allocation’ option to something that you want to change memory_limit of php in virtualmin
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
While trying to run any of the following with Laravel composer installer, you see an error similar to the following:
Uncaught ErrorException: require(/home/username/public_html/vendor/composer/../../app/Helpers/helper.php): failed to open stream: No such file or directory in /home/username/public_html/vendor/composer/autoload_real.php:71
How to fix this?
Solution
The error is appearing, most likely you forgot to add the ‘app’ directory of laravel in your root directory. Make sure, you have the ‘app’ directory in your root directory, then run any of the following:
If this is the first time, you need all laravel packages, run:
composer install
If this is not the first time, you may run the following:
When run the following command in your Laravel Automation Tool Dusk:
php artisan dusk
You get something like the following error:
[elastic-keldysh@pl1 blog]$ php artisan dusk
PHPUnit 9.3.11 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 00:00.339, Memory: 18.00 MB
There was 1 error:
1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\UnknownErrorException: unknown error: cannot find Chrome binary
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:139
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:370
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:136
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/tests/DuskTestCase.php:40
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:200
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/framework/src/Illuminate/Support/helpers.php:234
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:201
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:95
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:65
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/tests/Browser/ExampleTest.php:21
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
The error actually appears because you do not have Chrome browser installed on your system. Now, exit from your user shell, and drop back to the root shell. From the root shell, if you are using CentOS 7, you may run the following:
Once the installation is done, you may now go back to the user shell and run laravel dusk:
[root@pl1 lib64]# su - elastic-keldysh
Last login: Thu Oct 1 15:39:18 IST 2020 on pts/0
[elastic-keldysh@pl1 ~]$ php artisan dusk
Could not open input file: artisan
[elastic-keldysh@pl1 ~]$ cd blog
[elastic-keldysh@pl1 blog]$ php artisan dusk
PHPUnit 9.3.11 by Sebastian Bergmann and contributors.
R 1 / 1 (100%)
Time: 00:02.367, Memory: 18.00 MB
There was 1 risky test:
1) Tests\Browser\ExampleTest::testBasicExample
This test did not perform any assertions
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/tests/Browser/ExampleTest.php:16
OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Risky: 1.
If you are looking at this post, chances high that, you are trying to run laravel dusk and seeing the following kind of error:
[elastic-keldysh@pl1 blog]$ php artisan dusk
PHPUnit 9.3.11 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 00:00.331, Memory: 18.00 MB
There was 1 error:
1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"binary":"","args":["--disable-gpu","--headless"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless"]}}}
Failed to connect to localhost port 9515: Connection refused
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:136
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/tests/DuskTestCase.php:40
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:200
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/framework/src/Illuminate/Support/helpers.php:234
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:201
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:95
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:65
/var/www/vhosts/elastic-keldysh.139-99-24-82.plesk.page/blog/tests/Browser/ExampleTest.php:21
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Chorme/Chromium browser runs it’s on 9515 port and laravel dusk tries to connect to it through the Browser binary, but failing to do so. To resolve the case, we first, need to check if chromedriver for linux can run or not.
First, browse your laravel root directory, in my case, it’s the blog directory and then run the chromedriver for linux as following:
cd blog
vendor/laravel/dusk/bin/chromedriver-linux
This should return something like the following if the driver able to load in memory:
[elastic-keldysh@pl1 blog]$ vendor/laravel/dusk/bin/chromedriver-linux Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully.
But if it can not be loaded, it will return some kind of error like the following:
[elastic-keldysh@pl1 blog]$ vendor/laravel/dusk/bin/chromedriver-linux
vendor/laravel/dusk/bin/chromedriver-linux: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory
As the error suggests, it is failing to access the library called libX11-xcb. To install it in CentOS, you may run the following from root shell:
You may now, go back to the user shell, and run the chromedriver-linux again:
[root@pl1 lib64]# su - elastic-keldysh
Last login: Thu Oct 1 15:28:29 IST 2020 on pts/0
[elastic-keldysh@pl1 ~]$ cd blog
[elastic-keldysh@pl1 blog]$ vendor/laravel/dusk/bin/chromedriver-linux
Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Now, you may run the following to start using the laravel dusk:
php artisan dusk
After you are done resolving the 9515 error, you might also have to face another error with Chrome Binary, have a look at the following on how to resolve the error:
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: