Magento Development and Deployment Toolkit using Phing. This can be used out of the box or modified to meet your needs.
Features:
- Packages and deploys magento to multiple servers reliably and securely.
- Provides Sass compilation and Javascript compression.
- Creates Symlinked development environment that exactly mirrors the deploy.
- Provides a way to share code between magento projects.
- Creates database / media snapshots from deployed environments for development.
- [Phing] (http://www.phing.info/trac/wiki/Users/Download)
- [VersionControl_Git] (http://pear.php.net/package/VersionControl_Git)
- [pecl-ssh2] (http://pecl.php.net/package/ssh2)
- [n98-magerun] (https://github.com/netz98/n98-magerun)
- [Compass] (http://compass-style.org/) (optional)
- [Closure Compiler] (https://developers.google.com/closure/compiler/) (optional)
To get your CentOS / RHEL 6.x development environment up install the following software as root. This guide assumes you already have the requirements to run magento and a JVM installed.
Install Phing and pecl-ssh2:
yum install php-pear-phing php-pecl-ssh2
Install VersionControl_Git:
pear install VersionControl_Git-alpha
Install n98-magerun:
cd /usr/local/bin
wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar
chmod +x n98-magerun.phar
Install Compass (for Sass compilation):
yum install rubygems
gem install compass compass-normalize
Install Closure Compiler (for Javascript compression):
cd /usr/local/lib/java
wget http://closure-compiler.googlecode.com/files/compiler-latest.zip
unzip compiler-latest.zip
- Copy example/build.xml to your magento project root, setting the project name.
- Copy example/build.properties and configure your project.
The following properties in build.properties control various aspects of the development and deploy process.
-
project.magento.edition: Which magento edition is this based from (enterprise|professional|community)
-
project.magento.version: What version of the magento edition. These project.magento properties determine which tar file is used to in the rebuild and package targets. You can configure where these archives live by setting magento.archive.dir.
-
project.git.remote: Git repository URL for the project, used when building the deploy package.
-
project.libs: A comma separated list of directories from the shared library repository to include when rebuilding, relinking and deploying.
-
project.libs.devlibs: A comma separated list of directories from the shared library repository to include when rebuilding, relinking BUT NOT when deploying.
-
project.libs.branch: The branch from the shared library repository to pull shared code from.
The following properties determine how environments are set up for deployment and backup. To add or remove environments you can modify the deploy.environments property in default.properties.
-
deploy.username: A user on all deployment servers which has permissions to deploy the application. Highly recommended to set this to ${phing.project.name}. Can be overridden via deploy.[environment].username.
-
deploy.[environment].host: A comma separate list of servers to deploy to.
-
deploy.[environment].password: The password for the deploy.username. If omitted the authentication will be handled with openssh public/private keys. You really shouldn't store passwords in plain text.
-
deploy.[environment].branch: The git branch to deploy from.
-
deploy.[environment].compressjs: When set to true will use the google closure compiler to compress all core and skin js used in the front end of the site. This will add up to 10 minutes to your build time, but reduces Javascript size by about 50%.
- Copy files in the server directory to all deployment servers.
- Create one or more users with the same name as each project deployed on the server.
-
setup_project: Sets up host file and Apache or nginx config for the project. Unlike the other tasks this must be run with root permissions. By default will configure apache. To change modify the default.properties file and set setup.webserver=nginx. After setting up Apache or nginx the project will be accessible from http://projectname.yourhostname.com/. In the build.properties file for the project you can define project.runcodes (comma separated), and project.runtype. These tell the setup-project task to create additional virtualhosts for the different websites / stores configured in Magento. In that case the default store will be available at http://projectname.yourhostname.com/ while the other websites will be available at http://projectname-runcode.yourhostname.com/.
-
rebuild: Creates the Magento runtime directory and lib directory (projectname_mage, projectname_lib), applies patch files located in the project root, and then runs relink. The lib directory is for code completion in your ide (add as a External Library in PhpStorm), while the runtime directory (projectname_mage) is the directory that actually runs your magento code.
-
relink: Deletes all symlinks in the project runtime directory (projectname_mage), and then symlinks in all custom code, the media directory, and var/sessions into the runtime directory. In the course of the development process you will need to run relink to see new modules, themes, skins, and locale files.
-
flush_cache: Clears the magento cache as configured in the local.xml.
-
backup: Creates an archive with media, local.xml, and database dumps from the specified environment.
-
restore_backup: Unpacks a backup archive and restores the database and media locally, requires a mysql user with privileges to drop and create databases configured in app/etc/local.xml.
-
compass_watch: Starts [compass] (http://compass-style.org/) watcher in all compass enabled skin directories.
To allow your various magento projects to share code you can configure a separate repository in phing/default.properties. Subdirectories of the git repository set in project.libs.remote are overlayed into the project library and runtime directory as well as the deployment package when the project build.properties specifies them in a comma separated list in project.libs. Projects can also define certain directories to include in the development environment but not in the deploy by setting a list of directories in project.devlibs. You can specify which branch from the lib repository is used by setting project.libs.branch.