Magento environment. Our way.

Hello guys. This is our first article. And we would like to tell you how we orginize Magento development environment in our company. As you know there is a major rule #1 for magento "Never ever edit the core". So how to prevent editing the core files? The simple way is adding all the Magento core files to .gitignore. Even if somebody modified this file they will not commit the changes. There is a good service that allows you to generate .gitignore files for a lot of projects But how we should up the environment in a simple way so even QA or designer can up it on their local machine? So follow these instructions

1. Repository

First of all you need to create a repo and commit your .gitignore file

#init repository
git init
#that's you repo address on github or bitbucket
git remote add origin
#stage file
git add .gitignore
#commit file with message
git commit -m 'Added .gitignore'
#push changes to master branch
git push origin master

If you already have a repo with changes you just need to run

git clone ./repo

2. Magento

You can download Magento here and unpack it to your project folder, or better way is to create a repository with clean Magento (or use the existing one and pull Magento files to the project). Second way is better because run list of instructions is more simple for people who have no idea what they're doing. So the following subitems are for people who chose the second way:

2.1 You need to add new remote 'magento' and fetch files from it
git remote add -f magento
2.2 After this need to merge Magento files to project without commit
git merge -s ours --no-commit magento/master
2.3 Then we should update the files with the result of merge
git read-tree --prefix='/' -u magento/master
2.4 And finally need to reset files because files were added to stage, but we don't need to commit Magento files
git reset .

3. Installation

Also you need to set 777 permission to the folders media/, var/, app/etc/ The final step is installing Magento or extracting existing database dump.

4. Instructions step-by-step.

After this we can make a list of commands that allows anyone to setup your magento project on local machine and it will prevent core files editing. The following instructions:

1. Clone your repo
git clone ./repo
2. Add magento remote
git remote add -f magento
3. Merge magento files to project
git merge -s ours --no-commit magento/master
4. Update files
git read-tree --prefix='/' -u magento/master
5. Reset
git reset .
6. Configure virtualhost
7. Extract Database dump and update web/secure/base_url and web/unsecure/base_url in table core_config_data to your values or run installation process
8. Configure your app/etc/local.xml (Note: only if you import Database)
9. Profit.

That's how you can configure Magento environment and prevent core files editing. Notice: There is one issue. When you install third party extensions to your project often they have a theme files placed into base/default folder, so you just need to copy all of these theme files (app/design, skin/) to your theme to be able commit them. That's all, we would like to hear about your experience in configuring Magento environment. Thanks for reading.

Blog Comments powered by Disqus.