git 考虑到供应商被忽略,如何克隆我自己的 Laravel 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34570826/
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 clone my own Laravel project considering vendor ignored
提问by Marco Aurélio Deleu
I'm looking for help on dealing with the whole setup process of a Laravel project. Currently this is my walkthrough list:
我正在寻找有关处理 Laravel 项目整个设置过程的帮助。目前这是我的演练列表:
- Install Virtual Box and Vagrant.
- Run
vagrant box add laravel/homestead
- Run
git clone https://github.com/laravel/homestead.git Homestead
on your favorite folder, using your favorite Bash (in my case I'm using Git BASH because I'm on Windows 10) - Setup your SSH Keys with
ssh-keygen -t rsa -C "[email protected]"
- Setup SSH connector file[1].
- Setup your Homestead.yaml as you wish.
- Run
init.sh
/init.bat
. - SSH into the Vagrant.
- run
composer global require "laravel/installer"
- run
laravel new project
- Go back to the host machine, into the project folder and run
git init
,git add .
,git commit -m "clean project"
- Push the project with
git remote add origin https://bitbucket.org/you/yourproject
andgit push -u origin --all
- 安装 Virtual Box 和 Vagrant。
- 跑
vagrant box add laravel/homestead
git clone https://github.com/laravel/homestead.git Homestead
使用您最喜欢的 Bash 在您最喜欢的文件夹上运行(在我的情况下,我使用 Git BASH 因为我在 Windows 10 上)- 设置您的 SSH 密钥
ssh-keygen -t rsa -C "[email protected]"
- 设置 SSH 连接器文件 [1]。
- 根据需要设置 Homestead.yaml。
- 运行
init.sh
/init.bat
. - SSH 进入 Vagrant。
- 跑
composer global require "laravel/installer"
- 跑
laravel new project
- 回到主机,到项目文件夹和运行
git init
,git add .
,git commit -m "clean project"
- 使用
git remote add origin https://bitbucket.org/you/yourproject
和推送项目git push -u origin --all
Now I have a brand new Laravel project hook up to Git for versioning. My problem is that Laravel ignores /vendor
by default. Considering this fact, I want to clone my project in another computer because I have 2 computers to work and/or a co-worker wants to clone the same project so we can work on it together.
现在我有一个全新的 Laravel 项目连接到 Git 以进行版本控制。我的问题是 Laravel/vendor
默认忽略。考虑到这一事实,我想在另一台计算机上克隆我的项目,因为我有 2 台计算机要工作和/或一位同事想要克隆同一个项目,以便我们可以一起工作。
What would be the proper walkthrough to clone the project and have Laravel work on another machine? Do I have to add /vendor
to the repository and push? Should I add the homestead box into the repository? If so, how?
克隆项目并使 Laravel 在另一台机器上工作的正确演练是什么?我是否必须添加/vendor
到存储库并推送?我应该将宅基地框添加到存储库中吗?如果是这样,如何?
Thanks in advance.
提前致谢。
[1]
Host homestead
HostName 127.0.0.1
User vagrant
Port 2222
回答by Denis Mysenko
Ensure that your Git repository includes composer.json (package settings) and composer.lock (optional, but recommended by Composer to ensure 100% version match across all servers) files, but doesn't include 'vendor' folder or .env file (at the moment it looks like you are adding everything with 'git add .' – which is not safe). A standard practice to deploy ('clone') your code would be:
确保您的 Git 存储库包含 composer.json(包设置)和 composer.lock(可选,但 Composer 推荐以确保所有服务器的 100% 版本匹配)文件,但不包含“vendor”文件夹或 .env 文件(目前看起来您正在使用 'git add .' 添加所有内容 - 这不安全)。部署(“克隆”)您的代码的标准做法是:
- git clone https://bitbucket.org/you/yourproject(on remote machine)
- cd yourproject
- composer install (this will create 'vendor' folder and download all packages)
- Create and edit .env file
- git clone https://bitbucket.org/you/yourproject(在远程机器上)
- cd 你的项目
- 作曲家安装(这将创建“供应商”文件夹并下载所有软件包)
- 创建和编辑 .env 文件
Pretty simple really!
真的很简单!
Moreover, you can find a number of services in Internet that can deploy your application automatically whenever BitBucket repository has updates.
此外,您可以在 Internet 上找到许多服务,它们可以在 BitBucket 存储库有更新时自动部署您的应用程序。