Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone my own Laravel project considering vendor ignored

I'm looking for help on dealing with the whole setup process of a Laravel project. Currently this is my walkthrough list:

  • 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[¹].
  • 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 and 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.

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?

Thanks in advance.

[¹]
Host homestead
HostName 127.0.0.1
User vagrant
Port 2222
like image 682
Marco Aurélio Deleu Avatar asked Jan 02 '16 21:01

Marco Aurélio Deleu


1 Answers

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:

  1. git clone https://bitbucket.org/you/yourproject (on remote machine)
  2. cd yourproject
  3. composer install (this will create 'vendor' folder and download all packages)
  4. Create and edit .env file

Pretty simple really!

Moreover, you can find a number of services in Internet that can deploy your application automatically whenever BitBucket repository has updates.

like image 186
Denis Mysenko Avatar answered Nov 06 '22 21:11

Denis Mysenko