Good afternoon,
I'm working on a symfony project and everything was going well until I received the following messages :
PHP Warning: Unsupported declare 'strict_types' in .../vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 19
PHP Parse error: parse error, expecting ';'' or '{'' in .../vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 97
These 2 messages appear whenever I try to use the command line in symfony.
I tried the following commands:
php app/console generate:doctrine:entity
and
php app/console cache:clear --env=prod.
I also tried to use php bin/console instead of app/console as I'm aware the new symfony versions use php bin/console.
I'm using Mamp with php version 7.1 and Symfony version 2.8 for the projects.
Thanks for your help!
If someone runs into this issue it means that your php version is not 7.0 The issue I had was that the Mamp version was 7.1.1 and the symfony project was also running on 7.1.1 in the browser but when I checked the php version in the bash commands, it was 5.6 so make sure you're bash commands use php 7.0 instead of 5.6
Related
I've deployed a laravel app on cpanel. The app is working as expected on my local machine but on cpanel I'm getting the error below.
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.30. in /home4/peakcoke/public_html/vendor/composer/platform_check.php on line 24
When I run php -v I get 8.0.20.
How can I fix this?
Do a phpinfo(), what you get by running php -v from terminal is PHP CLI version.
Also, Cpanel usually comes with PHP Selector component that allows you to switch between different installed versions.
I installed laravel project 5.1 which is working fine but artisan commands are not working throwing each() error which is deprecated in php 7.1. When I run phpinfo() it shows php version 5.6 and on command line there's also two versions are showing
when run
phpinfo();
5.6
when run on command Line in xampp folder
C:/xampp> php -v;
5.7
when run in command in this xammpp/php directory
C:/xampp/php> php -v;
5.6
This is because there are CLI version and WEB version.
How Giacomo1968 says in this answer on Super User:
“Don’t panic! If you are concerned about what PHP version your Apache server is using, the output of phpinfo() is always what you should pay attention to. The Apache PHP module and the PHP command line binary are two different things that don’t interfere with each other.
In fact you can compile and load various PHP versions you want to work with Apache as long as you adjust Apache to properly load it. The PHP command line interface will never come into play in the case of Apache parsing PHP pages.
The command line version of PHP is simply there for command line specific tasks and the PHP module for Apache will never touch, use or need that.”
I’ve successfully installed PHPUnit, but I am running into some problems. When I try to run it on the command line, I get this message:
> “PHPUnit 8.0.4 by Sebastian Bergmann and contributors. This version of
PHPUnit is supported on PHP 7.2 and PHP 7.3. You are using PHP 7.1.23
(/usr/bin/php).”
When I type “php –v” in the command line, the system verifies that I’m using version 7.1.23 of the language.
When I tried to install PHP 7.3.2, Homebrew gives me the following message:
“Warning: php 7.3.2 is already installed, it's just not linked You can
use brew link php to link this version."
When I try to link, it tells me:
"Linking /usr/local/Cellar/php/7.3.2... Error: Could not symlink
sbin/php-fpm /usr/local/sbin is not writable.”
So PHP 7.3.2 does exist on my system, but PHPUnit is not detecting it. Would you happen to know of any fix for this? Is there a way to switch to 7.3.2, or to perhaps install an earlier release of PHPUnit that’s compatible with PHP 7.1.23?
Thanks in advance for any help you can give.
Maybe you should just try with sudo?
sudo brew link php
Edit: It's not a good idea. Please ignore.
I just setup php 7.0.27 in both webserver and cli. My laravel project was working just fine before in php 7.2. When I try run command php artisan serve it shows an error:
PHP Parse error: syntax error, unexpected '?', expecting variable
(T_VARIABLE) in /var/www/html/pmanager/pmanager/vendor/symfony/console
/Output/Output.php on line 40
I followed this github discussion which says that the solution is installing same versions in cli and webserver, which, in my case is fine. I have 7.0.27 in both.
Another thing they are pointing it out is laravel shows this error with php 7.0. I cannot change my php version to 7.1 or 7.2 because I must stick with it so as to run magento 2.1 projects.
Any help without changing php version would be highly appreciated.
you can downgrade your laravel 5.6 project to 5.5!!
Changing the value of the Laravel version inside the composer.json file to the laravel 5.5.
Delete /vendor folder and run composer install
I followed this guide and then I added /usr/local/bin before the whole $PATH variable so that the newly installed version runs first (instead of the default one).
Then when I tried to run php -version from the command line, I get the following error :
Parse error: syntax error, unexpected end of file in Command line code on line 1
I am running Mountain Lion.
It seems that php -version is deprecated for php v5.4.x
I tried php -v and it works for both php 5.3.x and php 5.4.x