Laravel Error: Cannot use lexical variable $key as a parameter name

Laravel Error: Cannot use lexical variable $key as a parameter name

If your cPanel PHP was updated recently then you will see this error on the website.

Solution:

You will have to update the composer packages. Go the the laravel main directory and run below command

 /opt/cpanel/ea-php73/root/usr/bin/php /opt/cpanel/composer/bin/composer update

Above is for site you using php 7.3. If you are using other php version then use the correct php path to that version.