Reputation: 2302
If I open Terminal on my MacOS and view my php version the result is:
Jacks-MBP:Projects jackrobson$ php -v
PHP 7.2.12 (cli) (built: Nov 29 2018 01:59:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.12, Copyright (c) 1999-2018, by Zend Technologies
I'm also running httpd as my Apache server:
Jacks-MBP:Projects jackrobson$ httpd -v
Server version: Apache/2.4.37 (Unix)
Server built: Nov 8 2018 08:13:24
However, upon trying to configure Laravel of which I did by running this command without any errors:
composer create-project laravel/laravel demowebsite
And configure my vhost, I see this error when I view demowebsite.test:
Parse error: syntax error, unexpected '=' in /Users/jackrobson/Projects/demowebsite/vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 384
I think maybe this because I don't have the dependencies needed?
Is that true or would the composer install of laravel failed?
I'm trying to figure out if the dependencies are missing.
Weirdly, upon looking at phpinfo from the base of the laravel demosite it says:
PHP Version 7.0.32
Not sure why it's not using version 7.2 as is visible in my Terminal.
Maybe that is issue.
I will investigate further and update but anyone with more wisdom who understands this, I'd appreciate a point in the right direction.
Many thanks
Edit:
Following user Caddy DZ's suggestion "Try configuring httpd to use php 7.2 instead or remove version 7.0 completely"
I was able to switch php versions using a script I initially configured php, apache, etc. last year
$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp
$ chmod +x /usr/local/bin/sphp
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
If that doesn't work for any observers, try this additional command:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
This script made it easy for me to change httpd php version with the command:
Jacks-MBP:Projects jackrobson$ sphp 7.2
Sorry, but [email protected] is not installed via brew. Install by running: brew install [email protected]
Jacks-MBP:Projects jackrobson$ brew install [email protected]
Which ran without errors and now httpd is using 7.2 and the Laravel install no longer shows the syntax error. Huzzah!
Thank you for your assistance Caddy DZ. :)
I hope these notes prove helpful to anyone who encounters a similar issue.
Upvotes: 1
Views: 140
Reputation: 11044
Try configuring httpd
to use php 7.2
as the default fpm
instead or uninstall version php 7.0
completely if you don't need it.
Hope this helped
Upvotes: 1