====== 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 9. 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. ===== 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 "esikuva". 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 | ===== 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 (c) 1997-2007 The PHP Group\\ Zend Engine v2.2.0, Copyright (c) 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 |esikuva | 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 esikuva;\\ mysql> CREATE DATABASE esikuva_dev;\\ mysql> CREATE DATABASE esikuva_tests;\\ \\ mysql> GRANT ALL ON esikuva.* TO alan@localhost IDENTIFIED BY "pass";\\ mysql> GRANT ALL ON esikuva_dev.* TO alan@localhost IDENTIFIED BY "pass";\\ mysql> GRANT ALL ON esikuva_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 esikuva'' ==== Set up project ==== Initialize your project without Subversion\\ ''mkdir -p ~/develop/php/esikuva/{trunk,branches,tags}\\ cd ~/develop/Software/akelos\\ ./script/setup ~/develop/php/esikuva/trunk/''\\ Ignore the last statement in the output which reads ''"Please point your browser to /home/alan/develop/php/esikuva/trunk in order to complete the installation process"''\\ \\ Import the new project into your repository, then initialize the working directory:\\ ''cd ~/develop/php/esikuva\\ svn import %%file:///home/alan/develop/repos/esikuva%% -m 'new project'\\ cd ..\\ rm -rf esikuva\\ mkdir esikuva''\\ \\ Check the project out of the repository into the working directory.\\ ''cd /home/alan/develop/php\\ \\ svn co %%file:///home/alan/develop/repos/esikuva/trunk esikuva%%''\\ \\ 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/esikuva/public/ esikuva\\ exit''\\ \\ Make sure that your project directory is writable for the webserver. Assuming that your webserver is Apache, do this:\\ ''su\\ cd ~/develop/php/esikuva/\\ chgrp apache . -R\\ chmod g+w . -R\\ exit''\\ \\ ==== Initialize project ==== Point your browser to http://localhost/esikuva.\\ Initialize your project according to the wizard.\\ \\ Update the Subversion status for the project.\\ * Display the Subversion status.\\ ''cd ~/develop/php/esikuva\\ svn status''\\ * For each line that starts with a '!', issue a delete for the file/directory on that line:\\ ''svn delete ''\\ * For each line that starts with a '?', issue an add for the file/directory on that line:\\ ''svn add '' ==== 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/esikuva/app/controllers/article_controller.php\\ /home/alan/develop/php/esikuva/app/helpers/article_helper.php\\ /home/alan/develop/php/esikuva/test/functional/controllers/article_controller.php\\ /home/alan/develop/php/esikuva/test/fixtures/app/controllers/article_controller.php\\ /home/alan/develop/php/esikuva/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' ''