Table of Contents

Using Akelos with Subversion

Subversion is a system that enables you to save different versions of your code. It also enables a group of people to work on the same project without the danger of one person overwriting another person's work. There are different version control systems. Subversion appears to be the most popular right now.

There are different ways to install each of these software projects. This entry is one person's implementation of Akelos and Subversion. You can learn how to get and install Subversion at http://svnbook.red-bean.com/en/1.1/pr02s06.html . You may have to modify these instructions for your operating system. Mine is Fedora 7.

There are different ways to do some of these tasks. This article describes only one way. There are some procedures that need be done only once. There are others that need to be done for every project.

Subversion是一个系统,他可以用不同的版本保存你的代码。同样,他还能够使工作在同一个项目的一组成员,不用担心一个成员覆盖了另一个成员的代码。有很多不同版本控制系统。现在看来Subversion是最流行的。

有很多的方法来安装每个项目的软件。这个条目是个人的Akelos和Subversion的实现。你可以从http://svnbook.red-bean.com/en/1.1/pr02s06.html学习如何获得和安装Subversion。也许你不得不因为你的操作系统而修改这些指令。我的系统是Fedora 7.

My environment

This describes where my stuff is. Obviously, you may do it differently, but this article will have examples that reference my choices, so I do need to tell you what they are:

Location of Directory Comment
Akelos ~/develop/Software Location of the software that you will download from the Akelos site.
Subversion repository ~/develop/repos You may have repositories in different locations for different projects or you may have a number of projects in one repository. Each project will exist in a different subdirectory. Having a repository in a shared directory is discouraged because it seems to cause Subversion errors. A link from a shared directory to a repository may be all right, though I haven't tested it.
Project ~/develop/php My project name is “ticket”. We will check out copies of the project from the repository to this directory.
Docroot /var/www/html This is the location for Apache access. Links must be made to this directory from the “public” directory of both Akelos and each project.
User root /home/alan The symbol '~' is a synonym for this directory

我的环境

这里描述的使我的资料。很明显,你也许操作的不同,但是这篇文章的实例和我的选择相关,所以我需要作一些说明。

位置 路径 备注
Akelos ~/develop/Software 你从Akelos站点下载的软件的位置。
Subversion repository.~/develop/repos 也许对于不同的项目在不同的位置都有Subversion repositories 或者在同一个repository有很多的项目.每个项目存在于不同的子目录下. 不推荐把repository放在共享的目录下,因为那样会引发错误。在共享目录下有一个repository的链接应该是没问题,但是我没有测试过。
Project ~/develop/php 我项目的名字 “ticket”. 我们将从repository把项目检出到这个目录。
Docroot /var/www/html 这个是Apache 访问的位置。Akelos和其他的项目”public”目录必须链接到这个目录。
User root /home/alan 这个符号'~'和这个目录是一个意思。

Things that need to be done only once:

Get Subversion

Getting Subversion is very dependent upon your operating system and (in the case of Linux) your distribution. Therefore, it is beyond the scope of this article. This link to Subversion's site may help: http://subversion.tigris.org.

Get Akelos

Go to where you want to install Akelos. Then get it from Akelos' Subversion trunk.
cd ~/develop/Software
svn co http://svn.akelos.org/trunk/ akelos

Create a link in your docroot to allow Apache to access pages in your Akelos software.
cd /var/www/html
ln -s ~/develop/Software/akelos/public/ akelos

Check PHP

Execute /usr/bin/env php -v to display the php version information. It should look something like this:

PHP 5.2.4 (cli) (built: Sep 18 2007 08:57:57)
Copyright © 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2007 Zend Technologies

If the output doesn't resemble the above, find a way to display your php version information. Suggestions are php -v or /usr/bin/php -v. Change the first line in each of the following files to reflect what works for you: script/console, script/generate, script/migrate, script/setup and script/test.

Things that need be done for each project

Set up databases

Databases and permissions need to be set up. Each database must have the following information:

Item Example value
Database hostname localhost
User alan
Password pass
Database root ticket

Beside creating the databases, this information will be used to set up your project. At a command line enter:
mysql -u root -p

mysql> CREATE DATABASE ticket;
mysql> CREATE DATABASE ticket_dev;
mysql> CREATE DATABASE ticket_tests;

mysql> GRANT ALL ON ticket.* TO alan@localhost IDENTIFIED BY “pass”;
mysql> GRANT ALL ON ticket_dev.* TO alan@localhost IDENTIFIED BY “pass”;
mysql> GRANT ALL ON ticket_tests.* TO alan@localhost IDENTIFIED BY “pass”;

mysql> FLUSH PRIVILEGES;
mysql> exit

Set up repository

Change to the directory you want for your repository. Create a repository for your project there.
cd ~/develop/repos
svnadmin create ticket

Set up project

Initialize your project without Subversion
mkdir -p ~/develop/php/ticket/{trunk,branches,tags}
cd ~/develop/Software/akelos
./script/setup ~/develop/php/ticket/trunk/

Ignore the last statement in the output which reads “Please point your browser to /home/alan/develop/php/ticket/trunk in order to complete the installation process”

Import the new project into your repository, then initialize the working directory:
cd ~/develop/php/ticket
svn import file:///home/alan/develop/repos/ticket -m 'new project'
cd ..
rm -rf ticket
mkdir ticket


Check the project out of the repository into the working directory.
cd /home/alan/develop/php

svn co file:///home/alan/develop/repos/ticket/trunk ticket


Create a link in your docroot to allow Apache to access pages in your project.
su
cd /var/www/html
ln -s /home/alan/develop/php/ticket/public/ ticket
exit


Make sure that your project directory is writable for the webserver. Assuming that your webserver is Apache, do this:
su
cd ~/develop/php/ticket/
chgrp apache . -R
chmod g+w . -R
exit


在Subversion之外初始化系统
mkdir -p ~/develop/php/ticket/{trunk,branches,tags}
cd ~/develop/Software/akelos
./script/setup ~/develop/php/ticket/trunk/

忽略最后的这条信息“Please point your browser to /home/alan/develop/php/ticket/trunk in order to complete the installation process”

把你的新项目导入到你的repository, 然后初始化工作目录:
cd ~/develop/php/ticket
svn import file:///home/alan/develop/repos/ticket -m 'new project'
cd ..
rm -rf ticket
mkdir ticket


把repository之外的项目放入工作目录下。
cd /home/alan/develop/php

svn co file:///home/alan/develop/repos/ticket/trunk ticket


在docroot现建立一个连接,是的Apache2能够访问你的项目的页面。
su
cd /var/www/html
ln -s /home/alan/develop/php/ticket/public/ ticket
exit


对于webserver来说确保你的项目目录是可写的. 你的webserver之Apache2的话,这样做:
su
cd ~/develop/php/ticket/
chgrp apache . -R
chmod g+w . -R
exit


Initialize project

Point your browser to http://localhost/ticket.
Initialize your project according to the wizard.

Update the Subversion status for the project.

cd ~/develop/php/ticket
svn status

svn delete <file/directory>

svn add <file/directory>

Write program

Create the needed files for your project. As each file is created, add it to Subversion with the svn add command.
./script/generate commands will display a list of the files generated:

./script/generate controller Article generates this list:

/home/alan/develop/php/ticket/app/controllers/article_controller.php
/home/alan/develop/php/ticket/app/helpers/article_helper.php
/home/alan/develop/php/ticket/test/functional/controllers/article_controller.php
/home/alan/develop/php/ticket/test/fixtures/app/controllers/article_controller.php
/home/alan/develop/php/ticket/test/fixtures/app/helpers/article_helper.php

Enter the svn add statements for each file:

svn add app/controllers/article_controller.php
svn add app/helpers/article_helper.php
svn add test/functional/controllers/article_controller.php
svn add test/fixtures/app/controllers/article_controller.php
svn add test/fixtures/app/helpers/article_helper.php

Occasionally, commit your work to the repository: svn commit -m 'comment'