Custom Laravel Base Project

Laravel has a great base project to start from when building a new app. However, I have found that I often start each project by making the same tweaks each time. These are tweaks such as enabling elixir, making a base layout template and adding an errors partial. So I wondered if I could reduce the time it took me to start the project. I am aware of tools such as Yeoman, but I wondered if I could use the tools that Laravel already had to help me out. As it turns out, there is.

There are two main ways to start a new Laravel project,

laravel new xxxx


composer create-project --prefer-dist laravel/laravel xxxx

Which led me to decide that I should use composers create-project method to start a new project from a fork of the laravel/laravel repo.

Here’s how you can do it:
Set up the forked repo so that it reflects the changes you make at the start of every project.
Clone the repo locally
Change composer.json name to my repos name e.g. votemike/laravel
Make other changes you want, add elixir, run npm and gulp on install, setup templates
Push back to your forked repo

You can then start a new project by running:

composer create-project votemike/laravel:dev-master --repository='{"type":"vcs","url":""}' xxxx

Periodically the Laravel base project will get updated and so your fork will be out of date. This is not a problem. This is how you can get your fork up-to-date:

Add the main laravel repo as upstream:

git remote add upstream

You can then rebase your fork on the Laravel repo. Do this with the following command:

git fetch upstream
git rebase upstream/master

If there are any conflicts, you can fix them. And then your fork is up to date.