简体   繁体   English

如何在Vagrant和Homestead中回滚PHP版本?

[英]How to roll back PHP version in Vagrant and Homestead?

So, my company is using PHP with Laravel for software development for clients. 因此,我的公司正在将PHP与Laravel一起用于客户端的软件开发。 I am new to the company and setting up a newer Macbook with VirtualBox, Laravel using Homestead, and Vagrant. 我刚接触公司,并使用VirtualBox,使用Homestead的Laravel和Vagrant设置了更新的Macbook。

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". 我已经进行了所有设置,以能够创建本地文件并将它们也绑定到VM中,但是任何时候我们尝试使用本地主机打开页面时,都会出现错误:“ Laravel需要Mcrypt PHP扩展名”。

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. 尽管他使用的是PHP和Laravel的较旧版本,但它在其他开发人员的Macbook上仍然可以正常工作。

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? 我的问题(我找不到相关的问题)是,我可以安装旧版本的laravel和PHP以便能够迫使我的VM项目仅在PHP 7.0版中打开吗? I found some posts that indicate that mcrypt is no longer supported on PHP 7.1+. 我发现一些帖子表明PHP 7.1+不再支持mcrypt。

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. 我们不得不将我们的项目强制安装到PHP 7.0中,最后使其正常运行。 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 我们删除了整个Laravel原始安装并使用此教程重新安装了该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. 最大的问题是试图允许在另一台使用不同版本的PHP的计算机上创建的项目在我的计算机上打开并运行。 Not an issue I had seen anywhere before. 这不是我以前在任何地方看到的问题。 To be fair, this is my first time ever working with Laravel. 公平地说,这是我第一次与Laravel合作。 I have a background in ASP.NET MVC 5 and this is an adjustment on getting the correct dependencies. 我在ASP.NET MVC 5中有背景,这是对获取正确依赖项的调整。

Again, thank you all for your responses!*** 再次感谢大家的回应!***

You can specify the PHP version in the Homestead.yaml file: 您可以在Homestead.yaml文件中指定PHP版本:

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

After making this change you will need to re-provision Homestead: 进行此更改后,您将需要重新配置Homestead:

vagrant reload --provision

See the Multiple PHP Versions section from the documentation . 请参阅文档中的“多个PHP版本”部分。

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

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