I think something like this:
return[
['php' => '/usr/local/php7.1/bin/php']
]
Thanks.
Peng
I think something like this:
return[
['php' => '/usr/local/php7.1/bin/php']
]
Thanks.
Peng
Please be more specific about what do you want to achieve.
My domain is hosted in a virtual server (linux Debian) with root access, no shared enviroment really.
I have installed Yii 2.0.11 advanced with composer and initiated it to the production enviroment. When the webRoot is called, it shown the following erros:
Warning: require(/home/www/ ... /frontend/web/../../vendor/autoload.php): failed to open stream: No such file or directory in /home/www/ ... /frontend/web/index.php on line 5
Fatal error: require(): Failed opening required '/home/www/ ... /frontend/web/../../vendor/autoload.php' (include_path='.:/usr/local/php7.1/lib/php') in /home/www/ .../frontend/web/index.php on line 5
The reason might be:
The server has more PHPs installed and provides different versions in consol(bash) and using scripts.
Alrough I set the PHP to 5.5 or 7.1 in the Controll Panel, the PHP version on the consol is always 5.3.29.
The installation and initiation were not able with PHP 5.3.29, so I had to used:
/usr/local/php7.1/bin/php
to make the processes.
If the path of PHP in Yii2 could be set by config to php7.1 , the problem might be solved.
By the way, the Yii 2.0.7 doesn’t have this problem on the same server.
Screen shoot:
...:~$ php -v
PHP 5.3.29 (cli) (built: Dec 29 2016 12:22:19)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
In yii2, the php version is 7.1, I have used phpinfo() to confirm it within the SiteController.
bin boot clamav ctrl dev etc home lib lib32 lib64 media mnt opt proc sbin selinux services srv start sys tmp usr var
bin ei games imagemagick man openssl php5.3-old php5.6 php7-old python-3.5 stunnel Zend5
bzr etc git include memcached php4 php5.4 php5.7 pngquant ruby-2.2 tmp
c-client ffmpeg-2.7.2 hg instantclient_12_1 nodejs php4-old php5.4-old php5-old python-2.7 sbin varnish
clamav ffmpeg-2.7.2.tar.gz hosting lib nodejs-0.6.8 php5 php5.5 php7 python-2.7.2 share wget
curl frontpage icu libpq nodejs4 php5.3 php5.5-old php7.1 python-3.2.2 src Zend4
bin etc include lib php var
The same error occured if using php7 or php5.5.
Nobody in the hosting company could solve the problem with the php versions.
Thanks in advance.
Peng
I think the requeirements are OK:
consol:
... $ /usr/local/php7.1/bin/php requirements.php
Yii Application Requirement Checker
This script checks if your server configuration meets the requirements
for running Yii application.
It checks if the server is running the right version of PHP,
if appropriate PHP extensions have been loaded, and if php.ini file settings are correct.
Check conclusion:
PHP version: OK
Reflection extension: OK
PCRE extension: OK
SPL extension: OK
Ctype extension: OK
MBString extension: OK
OpenSSL extension: OK
Intl extension: OK
ICU version: OK
ICU Data version: OK
Fileinfo extension: OK
DOM extension: OK
PDO extension: OK
PDO SQLite extension: OK
PDO MySQL extension: OK
PDO PostgreSQL extension: OK
Memcache extension: WARNING!!!
Required by: MemCache
APC extension: WARNING!!!
Required by: ApcCache
GD PHP extension with FreeType support: OK
ImageMagick PHP extension with PNG support: WARNING!!!
Required by: Captcha
Memo: Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.
Expose PHP: WARNING!!!
Required by: Security reasons
Memo: "expose_php" should be disabled at php.ini
PHP allow url include: OK
PHP mail SMTP: OK
Errors: 0 Warnings: 4 Total checks: 23
run it on the consol wite PHP7.1, OK:
... :~/www/ ... /frontend/web$ /usr/local/php7.1/bin/php index.php
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-param" content="_csrf-frontend">
<meta name="csrf-token" content="U1dnSGJfR2FhYAkxFmwtLyVnUz8mJi0.PGcRPzYTcBYFZ1QADGYAUQ==">
<title>My Yii Application</title>
<link href="./assets/222c5bd/css/bootstrap.css" rel="stylesheet">
<link href="./css/site.css" rel="stylesheet"></head>
<body>
<div class="wrap">
<nav id="w0" class="navbar-inverse navbar-fixed-top navbar" role="navigation"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w0-collapse"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span></button><a class="navbar-brand" href="index.php">My Company</a></div><div id="w0-collapse" class="collapse navbar-collapse"><ul id="w1" class="navbar-nav navbar-right nav"><li class="active"><a href="index.php?r=site%2Findex">Home</a></li>
<li><a href="index.php?r=site%2Fabout">About</a></li>
<li><a href="index.php?r=site%2Fcontact">Contact</a></li>
<li><a href="index.php?r=site%2Fsignup">Signup</a></li>
<li><a href="index.php?r=site%2Flogin">Login</a></li></ul></div></div></nav>
<div class="container">
<div class="site-index">
<div class="jumbotron">
<h1>Congratulations!</h1>
<p class="lead">You have successfully created your Yii-powered application.</p>
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
</div>
<div class="body-content">
<div class="row">
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">&copy; My Company 2017</p>
<p class="pull-right">Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a></p>
</div>
</footer>
<script src="./assets/7b02cf58/jquery.js"></script>
<script src="./assets/797f765e/yii.js"></script>
<script src="./assets/222c5bd/js/bootstrap.js"></script></body>
</html>
with php5.3.29:
... :~/www/ ... /frontend/web$ php index.php
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/www/ … /frontend/web/index.php on line 17
Yii 2 requires at least PHP 5.4 so it’s expected to fail with 5.3. If you’re not using PHP 5.3 then I’d suggest replacing binary with a symlink to PHP 7.1.
Is there no chance to config php version to be used within Yii2?
I made:
alias php='/usr/local/php7.1/bin/php'
but no effect.
I would say that is a bug:
see:
Sorry, I have no idea why it fails. There were no related changes since 2.0.7 as far as I know. If you’ll find out a reason, please report it to issue tracker. Thanks.
try composer update