Magento & Subversion (SVN) - Getting a Development Environment Started?
Categories:
Setting Up a Magento Development Environment with Subversion (SVN)

Learn how to establish a robust Magento development environment using Subversion (SVN) for version control, ensuring collaborative development and easy deployment.
Setting up a development environment for Magento, especially when working in a team, requires a reliable version control system. Subversion (SVN) is a popular choice for managing code changes, tracking revisions, and facilitating collaboration. This article will guide you through the process of configuring a Magento development environment with SVN, covering repository setup, local checkout, and essential workflow considerations.
Understanding the SVN Workflow for Magento
Before diving into the technical steps, it's crucial to understand the typical SVN workflow in a Magento development context. This involves a central repository, developers checking out code, making changes, committing them, and updating their local copies. A clear branching strategy is also vital for managing different development lines (e.g., features, bug fixes, releases).
flowchart TD A[SVN Repository] --> B{Developer 1: Checkout} A --> C{Developer 2: Checkout} B --> D[Developer 1: Make Changes] C --> E[Developer 2: Make Changes] D --> F{Developer 1: Commit} E --> G{Developer 2: Commit} F --> A G --> A A --> H{Developer 1: Update} A --> I{Developer 2: Update} subgraph Local Development D E H I end
Basic SVN Development Workflow
Setting Up the SVN Repository
The first step is to create your SVN repository. This can be hosted on a dedicated server or a cloud service. For Magento, it's common to structure the repository with trunk
, branches
, and tags
directories. The trunk
will hold the main development line, branches
for feature development or bug fixes, and tags
for stable releases.
# Create a new SVN repository
svnadmin create /path/to/your/svn/repo/magento_project
# Create the standard directory structure
mkdir -p /tmp/magento_project_structure/{trunk,branches,tags}
svn import /tmp/magento_project_structure file:///path/to/your/svn/repo/magento_project -m "Initial repository structure"
Creating an SVN repository and its standard directory structure.
Initial Magento Project Import and Local Checkout
Once the repository is ready, you'll import your Magento project into the trunk
. This usually involves a clean Magento installation. After the initial import, developers can check out the project to their local development environments.
1. Prepare Magento Installation
Perform a clean Magento installation on your local machine. Ensure all core files are present and the application is functional. Remove any generated files (e.g., var/cache
, var/session
, var/log
, pub/static/_cache
) before importing to keep the repository clean.
2. Import Magento to SVN Trunk
Navigate to your local Magento root directory and import it into the SVN trunk
. This will be the base version of your project in version control.
cd /path/to/your/local/magento_root
svn import . svn://your-svn-server/magento_project/trunk -m "Initial import of Magento project"
3. Perform Local Checkout
After the import, remove your local Magento directory (or move it) and perform a fresh checkout from the SVN trunk
to ensure your working copy is properly linked to the repository.
rm -rf /path/to/your/local/magento_root
svn checkout svn://your-svn-server/magento_project/trunk /path/to/your/local/magento_root
4. Configure Local Environment
Set up your web server (Apache/Nginx), database, and PHP for the checked-out Magento project. Remember to create necessary writable directories (e.g., var
, pub/static
, app/etc
) and adjust permissions. You'll also need to configure app/etc/env.php
and app/etc/config.php
for your local database.
app/etc/env.php
directly to SVN, as it contains database credentials and other environment-specific settings. Use a .gitignore
(or equivalent for SVN, though less direct) or ensure these files are excluded. A common practice is to commit a template file (e.g., env.php.sample
) and have developers copy and configure it locally.Managing Magento Specific Files with SVN
Magento generates a lot of files that should not be committed to SVN, such as cache, session, log files, and compiled static assets. Properly ignoring these files is crucial for a clean and efficient repository.
# Example of SVN ignore properties for a Magento project
# Navigate to the Magento root
cd /path/to/your/local/magento_root
# Ignore common Magento generated directories
svn propset svn:ignore "var
media
pub/static
app/etc/env.php
app/etc/config.php
.idea
.DS_Store
.htaccess.sample
composer.lock
vendor" .
# Commit the property changes
svn commit -m "Added SVN ignore properties for Magento generated files and sensitive configs."
Setting SVN ignore properties for a Magento project to exclude generated and sensitive files.
.gitignore
, you can set svn:ignore
properties on directories. These properties are versioned, so once committed, all developers will benefit from the ignore rules.