从存储库运行 laravel sail 的项目
在进一步讨论之前,我一直在到处寻找如何在没有任何本地环境的情况下克隆存储库后正确运行 laravel sail 的项目(包括 MySQL、Redis 等)。 我已经阅读了其他一些问题和解释,但仍然没有任何完整/正确的答案。
我尝试使用 sail 创建一个新的 laravel 项目,然后上传到 git,并使用不同的方法将其再次克隆到我的本地计算机文件夹,然后尝试了上述所有链接。
- 例如,对于 MySQL,我尝试添加 php artisan migrate 或运行 sail artisan migrate 并显示连接被拒绝。
- 我尝试在运行
sail up
之前先构建 - 我尝试复制env示例文件
到目前为止,我只能运行sail(我可以访问网页),但不能运行数据库等。
谢谢。
Before going any further, I've been looking everywhere on how to run laravel sail's project (including MySQL, Redis, etc) properly after cloning a repository without any local environments.
I have read some another questions and explanations, but still didn't have any completed/proper answers.
- this answer only tell of how to have sail in that project
- this question has no answers until this question posted
- this one also only tell of how to have sail in that project
I have tried to create a new fresh laravel project by using sail, then upload to git, and clone it again to my local machine with using different folder, then tried all of above links.
- e.g For MySQL, I have tried to add
php artisan migrate
or runsail artisan migrate
and it showed connection refused. - I have tried to build first before run
sail up
- I have tried to copy env example file
Until now, I only can run the sail (I can access the webpage) but not the databases and so on.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您提供的信息重现步骤,这就是我所做的:
注意:我假设您已经安装了 docker。
curl -s https://laravel.build/test-app | bash
sail up
(等到输出停止)只是为了测试它,您可以在之后sail down
:.env.example
复制到.env
。我将其127.0.0.1
更改为localhost
。在DB_HOST
中将值更改为mysql
./vendor/bin/sail/up
,应用程序将启动。在浏览器上打开应用程序(如果未更改端口,则为 localhost:80)。./vendor/bin/sail artisan key:generate
./vendor/bin/sail artisan migrate
一切顺利。希望对您有所帮助!
Reproducing the steps based on the information you provided this is what I did:
Note: I will assume you already have docker installed.
curl -s https://laravel.build/test-app | bash
sail up
(wait until the output stops) just to test it out, you cansail down
after:docker ps
if there is any container running (running container can cause issues if you don't change Ports). If any container is running stop them withdocker container stop <name of container OR ID of container>
.env.example
to.env
. I changed where it has127.0.0.1
tolocalhost
. In theDB_HOST
change the value tomysql
./vendor/bin/sail/up
and the app will start. Open the app on the browser (localhost:80 if you didn't change ports)../vendor/bin/sail artisan key:generate
./vendor/bin/sail artisan migrate
And you are good to go. Hope that it helps!
有时我对现有卷有问题,这些卷存在但已经构建了所有内容。因此,即使我添加一个新项目,它仍然使用不正确的卷。
请阅读下面的内容,它解释得更好。
Laravel Sail 重建默认数据库
所以我通常做的是在本地使用代理服务器开发人员。这样我就可以使用不同的项目并让它们一起交流。
编辑:: 我用于本地开发的解决方案
https://blog.devgenius.io/multi- laravel-sail-sites-with-custom-domain-e13c07d9dd0c
Sometimes I have issues with existing volumes, those volumes exist but already have everything build. So even if i add a new project it still uses the incorrect volume.
please read below it explains it a lot better.
Laravel Sail rebuild default database
So what I normally do is use a proxy server on my local dev. so I can use different projects and can let them communicate together.
Edit:: the solution i used for local development
https://blog.devgenius.io/multi-laravel-sail-sites-with-custom-domain-e13c07d9dd0c