Using git and Symphony CMS

In this guide, I'll show you how to create a new git repository for your next Symphony project.

First things first, you'll need a fresh copy of Symphony, so head to the Symphony website then download and extract the latest release.

The repository

Take the downloaded folder, and place it in your local server folder, now would be a good time to rename the it to whatever you want to call your site.

Once you've got it in place, you need to create a .gitignore file:

*.esproj
*.tmproj
.Apple*
.DS*
.htaccess
manifest

This file contains any files and folders that you do not want to be tracked by git. Now it's time to initialise git and add all the files (ignore more files if you wish):

$ git init
Initialized empty Git repository in your repository
$ git add .

You can now commit the first commit:

$ git commit -m "Initialised repository."

The manifest

The manifest folder is always a pain — but here's how to set it up correctly. We're going to manage two separate manifest folders, one for live and one for development.

Before we do that though, we will tweak the manifest folder that came with Symphony. Create the following ignore files:

manifest/cache/.gitignore
manifest/logs/.gitignore
manifest/tmp/.gitignore

And fill each file with the following content:

*
!.gitignore

This tells git to ignore every file except for the ignore file itself, which is handy as git won't try and merge temp files or logs.

Now, we will use this manifest folder to create our live and development manifests, just run the following command:

$ cp -r manifest manifest.live
$ mv manifest manifest.dev

Now all you need to do is create a symbolic link from manifest to manifest.dev or manifest.live depending on where you are:

$ ln -s manifest.dev manifest

This will let you share your manifest folder with other developers, and let you examine and update the live site's manifest folder before taking it live.

Finally, add the manifest folders and commit:

$ git add manifest.live manifest.dev
$ git commit -m "Added live and development manifest folders."

And you're done

Just add any extensions you need as git submodules, and start developing your site.

Share your thoughts...

Henry wrote on :

This is a really neat way of solving the differing manifest issue. How do you deal with keeping db changes in sync between developers? (ie sections and entries)

Nick Dunn wrote on :

Nice one, thanks Rowan.

You say to download from the website directly, presumably as zip file. Is there a simple way of cloning Symphony from github instead? The scenario I have in mind is:

  • a clone Symphony to create a new website
  • I add extensions as submodules

But then I want to make this entire thing a new repository for my named website, so that I can update Symphony in the future directly from git. Is this even possible?

Rowan Lewis wrote on :

Henry, with wishes and dreams.

Nick, you could in theory just clone the Symphony repository, but I think you'd run into conflicts with the workspace and extension submodules.

So it would be better to just update the relevant folders.

Nick Dunn wrote on :

That's what I was worried you'd say.

Maybe this is one reason in favour of using SVN to store projects. Your Symphony git repo could sit in the root of your SVN project, allowing you to update both independently.

Ha. Ok. No.

craig zheng wrote on :

Well done.

I actually have several sites as Git repos that are clones of the official repo. My master branch stays synced with official, and a dev branch has the manifest, workspace, and additional submodules added in.

When I want to update Symphony, I just checkout master and pull. Because I'm never committing anything on the master branch there are never problems. All that's required then is to merge master into dev.

The only time I've ever gotten a conflict is when a new core extension gets added (e.g. XSS Filter) which creates a conflict in .gitmodules if you've added any submodules yourself. That's an easy fix. Other than that, I've not had any issues.

The dev branch then gets pushed to some other remote, for me usually on Codebase.

John Porter wrote on :

I like this Rowan, especially the part about the manifest folders.

Am I ok to reference that part in an article I'm writing for Symphony? Credit will be shown...

Mark Lewis wrote on :

Thanks Rowan.

I just tried this on Windows 7. Just need to use:

mklink /D manifest manifest.dev

Marcio Toledo wrote on :

Rowan, nice post. I can merge this idea with this way of deploy with git. http://toroid.org/ams/git–website–howto

Ok, about config file, if I have new extension that changes it, I need manually copy config file (part of this file) to server right?