Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

naspy971's avatar

PHP Parse error: parse error, expecting `'&'' or `"variable (T_VARIABLE)"' on HOMESTEAD

Hi,

[UPDATE] After updating my mac php version from php 5.5 to 7.2 now it works, but the question below still remains...

I know this subject has been treated many times, but my case seems different, obviously.

I got this error when trying to create a controller.

From what I've read, this issue comes because of the php version used in the application.... ok.

I'm using Homestead as my dev environment, and after phpinfo()..ing on my welcome page, I checked that It runs php 7.2.*.

My mac currently runs php 5.5 and I'm at the moment I'm creating this post, trying to install newer version...

I guess when I will manage updating it, it will get fixed since it used to work before I applied some modifications on the .bash_profile lately because of another issue I had.

What I don't understand though, is that the application clearly says that it runs php 7.2 version in Homestead, so my php version on my mac has normally nothing to do with it.

What's happening then ?? Homestead can't stand by itself ?

Thanks.

0 likes
4 replies
Cronix's avatar

is the cli version 7.2 as well? How did you try to create the controller? Via artisan? Were you ssh'd into homestead when running artisan?

naspy971's avatar

Hum you mean the cli version of Homestead, or OSX ? How do I check this actually ?

I did it with artisan and I never use ssh on Homestead, haven't found a real utility for it yet...

Cronix's avatar
Cronix
Best Answer
Level 67

That would most likely be why it wasn't working. Artisan uses the CLI version of php, not the web version. So if you were trying to run artisan on your mac, and didn't have 7.2 installed, that's why you got the error.

Just run php -v from the cli to see the version.

It would have worked if you were ssh'd into homestead when running the artisan command, since it would have used the php version on that machine.

I'm using Homestead as my dev environment, and after phpinfo()..ing on my welcome page, I checked that It runs php 7.2.*.

Yes, that shows the web version installed.

1 like
naspy971's avatar

@Cronix Yes I actually did php -v to know that my mac runs php 5.5, and by what you told me, now I know the issue... I updated to 7.2 so now it runs normally.. Maybe i'll give vagrant a try in the future...

Issue resolved for me, thanks !

Please or to participate in this conversation.