0

I am new to Laravel, Laravel Homestead, Composer, and the development workflow associated with commiting changes to a Git repository and then pulling those changes to a development/production server. So far after much trial and error, I have managed to:

  1. Set up my local Homestead environment with vagrant.
  2. Create a new Laravel application
  3. Run Composer to fetch dependencies
  4. Access the application locally.
  5. Create a Git repository for my application, commit changes, and push to an origin master branch.
  6. Clone the repository on my remote server (shared hosting on 1and1) and pull the changes in.

For a long time, I couldn't understand why when I pulled the changes to the remote site, I would get PHP errors, but the local site ran just fine. It came down to the fact that the Laravel .gitignore file was ignoring the /vendor directory, which Laravel requires to function. Some Google-fu searches indicate that some people simply run composer update / (composer install ?) on their production servers. (I don't have access to Composer on my shared hosting server, so I am unable to do this)

My question to the community - what do you feel is the best workflow for my given situation? remove the /vendor directory from the .gitignore file? Something else?

Replies are much appreciated.

4 Answers 4

1

It looks like you are using GIT as a deployment tool which I dont think is a good idea.

Composer update/install is just for managing dependecies. Some servers dont allow you to run scripts from console or running them is complicated. In this situation you can run composer locally before deployment and send your code to server with all dependencies.

Here are some things that you should keep in mind when designing your workflow:

  1. Use GIT to keep source code and configurations
  2. Use composer to manage dependecies (downloaded dependencies should't be under version control in your GIT repository. Vendor directory and its contetnt is a dependency too)
  3. For deployment use one of deployment tools eg. https://github.com/rocketeers/rocketeer
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the suggestions, I will check out rocketeer.
1

use the -f flag to forcefully include the vendor directory while using git add.

Comments

0

You are on the right track here, and many will do what you are doing.

The real trouble comes when you are doing multiple server deployments (load balanced, auto-scaling).

Typically what I've seen is a shell script that you would include and run whenever something happens that would require these commands to be run.

Inside of this shell script would be the commands that you want completed every time a new server instance is booted up.

You can do this with a number of tools for a single server environment as well.

I might look into continuous integration tools like Travis CI, Jenkins, etc. If this is a major headache of yours.

Otherwise, it might be overkill.... then just keep doing what you are doing.

adding the vendor directory to your git repo is against best practices.

This is also a decent option involving webhooks: http://losstopschade.de/post/96967373358

Comments

0

Look at Deploy Laravel Webapp to 1and1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.