laravel 如何从本地网络访问laravel valet 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44697753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to access laravel valet project from local network?
提问by telee
I built a laravel project in my desktop folder and running it using valet on project-name.dev . How can I access it from local network ? My IP address is 192.168.1.5 ,I'm using a mac and I tried below code but It gives me a error in my project. Is there any different solution ?
我在我的桌面文件夹中构建了一个 laravel 项目,并在 project-name.dev 上使用 valet 运行它。如何从本地网络访问它?我的 IP 地址是 192.168.1.5 ,我使用的是 mac 并且我尝试了下面的代码,但是它在我的项目中给了我一个错误。有什么不同的解决方案吗?
php artisan serve --host 192.168.1.5 --port 80
Any help will be appreciated!!
任何帮助将不胜感激!!
回答by manud99
You forgot the equals sign in your command. It should work like this:
您忘记了命令中的等号。它应该像这样工作:
php artisan serve --port=80 --host=192.168.1.5
To connect any of your local network devices to your mac you can type into their browser's address bar:
要将任何本地网络设备连接到 Mac,您可以在浏览器的地址栏中键入:
192.168.1.5:80
回答by sumit
You can follow the step below
您可以按照以下步骤操作
Make valet site unsecure 1st using
valet unsecure sitename
Run
valet share
使代客站点不安全第一次使用
valet unsecure sitename
跑
valet share
A publicly accessible URL will be inserted into your clipboard and is ready to paste directly into your browser. That's it.
一个可公开访问的 URL 将插入您的剪贴板,并准备好直接粘贴到您的浏览器中。就是这样。
Please note
请注意
valet share does not currently support sharing sites that have been secured using the valet secure command.
valet share 目前不支持使用 valet secure 命令保护的共享站点。
https://laravel.com/docs/5.6/valet#sharing-sites
回答by Kofi Mokome
You can do that by using --host=0.0.0.0
你可以通过使用做到这一点 --host=0.0.0.0
So you type php artisan serve --host=0.0.0.0 --port=80
then go to your browser on another computer on the same network and type your IP address (192.168.1.5) then the port 192.168.1.5:80
因此,您输入php artisan serve --host=0.0.0.0 --port=80
然后转到同一网络上另一台计算机上的浏览器并输入您的 IP 地址 (192.168.1.5) 然后输入端口192.168.1.5:80