简体   繁体   English

在Mac中升级php时出错

[英]error upgrading php in mac

I am running OSX El Capitan (version 10.11.6). 我正在运行OSX El Capitan(版本10.11.6)。

I had php 5.5 installed. 我安装了PHP 5.5。

Phpunit requires php5.6 and more so I tried to upgrade my php to 5.6. phpunit需要php5.6及更高版本,因此我尝试将php升级到5.6。 I couldn't do it so I gave php7 a try. 我做不到,所以我尝试了php7。

I followed these guides: 我遵循了这些指南:
https://coolestguidesontheplanet.com/upgrade-php-on-osx/ https://coolestguidesontheplanet.com/upgrade-php-on-osx/
https://php-osx.liip.ch/ https://php-osx.liip.ch/
Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28? Mac将PHP升级到5.6,但是CLI php -v得到5.3.28?

My current output with php -v is : 我当前用php -v输出是:
PHP 7.0.12 (cli) (built: Nov 1 2016 10:21:11) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans

Funny thing, my output with a phpinfo(); 有趣的是,我的输出带有phpinfo(); when called from somewhere inside a Symfony project, is still PHP Version 5.5.36 从Symfony项目中的某个地方调用时,仍然是PHP Version 5.5.36

Any ideas?? 有任何想法吗??

Terminal uses a different PHP than a HTTP server in browser. 终端使用与浏览器中的HTTP服务器不同的PHP。 You can check what PHP you're using in CLI (command line interface) by this terminal command: 您可以通过以下终端命令检查CLI(命令行界面)中正在使用的PHP:

$ which php

I don't know if you use any AMP stack (like MAMP). 我不知道您是否使用任何AMP堆栈(例如MAMP)。 They include their own PHP, so you need to update them in order to have a different PHP version in browser. 它们包括自己的PHP,因此您需要对其进行更新才能在浏览器中具有不同的PHP版本。

Maybe you can use this trick to determine what PHP versions you use in browser / CLI : Find the php.ini path in your phpinfo() output and compare it with this terminal command: 也许您可以使用此技巧来确定您在浏览器/ CLI中使用的PHP版本 :在phpinfo()输出中找到php.ini路径,并将其与此终端命令进行比较:

$ php -i | grep php.ini

It's always a good idea to use the debug URL to troubleshoot your Symfony projects; 使用调试URL对Symfony项目进行故障排除总是一个好主意。 to use this, simply append: 要使用此功能,只需附加:

app_dev.php

For example if your route was like http://myhome/ , then you would use: 例如,如果您的路线类似于http://myhome/ ,则可以使用:

http://myhome/app_dev.php

Then on the bottom of your browser you will have the Symfony debug bar. 然后,在浏览器底部,您将拥有Symfony调试栏。 In the bottom right corner, the version of Symofny is shown, an if you move your mouse over it, you will see the version of PHP; 在右下角显示了Symofny的版本,如果将鼠标移到它上面,将会看到PHP的版本; plus also a link to "View phpinfo()". 以及指向“查看phpinfo()”的链接。 You can click on it to view the full PHP information, including where the PHP file is located. 您可以单击它以查看完整的PHP信息,包括PHP文件所在的位置。

The PHP config file used (shown on the phpinfo() page) is shown by: 使用的PHP配置文件(显示在phpinfo()页上)显示为:

Loaded Configuration File

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM