3

We're building our first webproject with laravel and angularjs and trying to figure out how to setup our development environment. Our current approach looks like this:

  • Backend git repo with laravel file structure
  • Frontend git repo with angularjs file structure

So some of us could work on the backend/frontend without the need of messing around with the frontend/backend files. Now, if there is a new version of e.g. a dev branch on the backend repo and I am working on the frontend, I want the frontend repo to automatically pull this new backend version from the git server and copy it into the development environment of the developer (on his workstation). That should guarantee that we can use the latest api routes in our frontend development.

The questions are:

  • Is there a way to automate this scenario?
  • Is it at all the best approach to seperate laravel and angularjs in two different repos? We also want to use some kind of task runner (like gulp) to build/package/minimize our frontend files (e.g. sass, less).
2
  • Can't the frontend devs just update the backend repo with git pull? May 6, 2015 at 11:21
  • Sure sounds pretty annoying if it's pulling the latest backend automatically on a persons development environment May 6, 2015 at 11:34

1 Answer 1

0

This answer is just one of the many ways to accomplish this and defining a "best approach" is quite relative.

1. Create separated virtual hosts to different branches (dev, release, master..)

In your Apache or Nginx, create different hostnames for different branches and, in each root directory (like public_html) pull the specific branch.

This way you allow your frontend devs to test multiple branches without compromising other devs.

2. Create a cron job to execute git pull periodically

This is not an optimized option but it is simple. Many complex solutions exist to auto pulling (like here and here) but, as I said, they are complex.

You can define an extremely short period to your cron job (like 5 or 10 minutes) since there are no problems when you pull and there aren't updates.

3. Establish a branching model

Probably you have one but, if not, define a branching model with your co-workers, like the old but gold Git branching model by Vincent Driessen.

One key aspect is that you allow your devs (both front and back) to work with their changes without affecting the others.

Usually each dev will only merge its local branch with the upper level after some tests (local to dev, dev to release, release to master), avoiding undesired error propagation.

This way each one can test its own code, including frontend devs using one of the backend virtual hosts to complete the test.

1
  • Tanks for the useful hints! I marked it as the right answer because you give a good overview about how to challenge the task.
    – Juke
    May 29, 2015 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.