简体   繁体   中英

How to roll back PHP version in Vagrant and Homestead?

So, my company is using PHP with Laravel for software development for clients. I am new to the company and setting up a newer Macbook with VirtualBox, Laravel using Homestead, and Vagrant.

I have gotten everything set up to be able to create local files and have them also tie into the VM, but anytime we try to open the pages using our local host, it gives us the error that "Laravel requires the Mcrypt PHP extension".

I have migrated all of our in-house files over to my local machine to be able to open them locally, but I can't get them to open even with being able to see them in the terminal. It works fine on the other developer's Macbook, although he is using an older version of both PHP and Laravel.

My question, which I cannot find a relevant question about, is can I install an older version of laravel and PHP to be able to force my VM project to open only with PHP version 7.0? I found some posts that indicate that mcrypt is no longer supported on PHP 7.1+.

Please include any relevant information you know of. We have been beating our heads against this issue all day yesterday and today. I'm sorry if this post seems noob-ish. I'm just not figuring it out.

***EDIT: We got it figured out today. We had to force our project into PHP 7.0 and finally got it working. We deleted the entire original Laravel installation and reinstalled using this tutorial: https://medium.com/@gdiasdasilva/creating-a-homestead-box-with-php-7-0-aaa72fb0e297

Thank you guys for your responses. Thankfully after two days, we worked our way through the issue. The biggest issue was trying to allow the project, which was created on another machine using a different version of PHP, to open and run on my machine. Not an issue I had seen anywhere before. To be fair, this is my first time ever working with Laravel. I have a background in ASP.NET MVC 5 and this is an adjustment on getting the correct dependencies.

Again, thank you all for your responses!***

You can specify the PHP version in the Homestead.yaml file:

sites:
    - map: homestead.test
      to: /home/vagrant/code/Laravel/public
      php: "7.0"

After making this change you will need to re-provision Homestead:

vagrant reload --provision

See the Multiple PHP Versions section from the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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