Contao and SVN Integration
I am frequently being asked about best practices in integrating a professional solution for code source management in the development of Contao modules. Actually, at a first glance, this may sound complicated, since Contao stores its modules in /contao/system/modules. Thus, if you are using Subversion, you should have a web structure like the following: /trunk/tags/branches. However, the solution to your problem is quite simple: all you need to do is create symbolic links.
Store your SVN repository at the root of your host directory or at the same level as Contao.
You should get something similar to the following:
Create a symbolic link by using the Shell prompt.
For Mac users:
cd /Applications/MAMP/htdocs/contao-version /system/modules
Create a symbolic link as follows:
ln -s /Applications/MAMP/htdocs/myModule/trunk myModule
This command may be repeated on all Contao applications. Thus, you have the same source code at the same time. If you are using an older version, the link may be created for tags:
ln -s /Applications/MAMP/htdocs/myModule/tags/version monModule
Make sure to replace the path with your own path as this example is using MAMP PRO. Also, replace the version with the version you are currently using and “myModule” with the name of your own module.
For PC users:
Right-click and run the command prompt as administrator.
Make a link between the chosen directory and the path of the version you are working with.
mklink /D "C:\Program Files (x86)\EasyPHP-version\www\contao-version\system\modules\myModule" "C:\Program Files (x86)\EasyPHP-18.104.22.168\www\myModule\trunk"
Make sure to replace the path name with your own as this example is using EasyPHP. Also, replace the version with the version you are currently using and “myModule” with the name of your own module.
For Linux users:
If you are a Linux user, then you certainly do not need any help since you are probably already the command line king.
There you go: you have just performed a link and had the module integrated in your Contao application. The advantage of such a procedure is that you comply with the SVN file naming convention, but at the same time, you also get to run your own module using the same source code on various Contao applications. All you need to do is repeat the application. This is the perfect way to test your module on several versions without risking any unnecessary copy modules.
What You Need to Know About Module File Naming With Contao
I strongly advise you against using pretentious file names containing special characters. Also, avoid using names that have already been taken. Last but not least, do not forget that the name of your file is written to the hard drive of your computer in /myModule/config/autoload.php.
For each new file, a slash is added (here is an example for newsletter modules):
'Contao\Newsletter' => 'system/modules/newsletter/classes/Newsletter.php',
Hence, you need to keep the name “newsletter” if you wish to place it in the “modules” files of Contao either as a physical file or as a symbolic link.
Minor Bugs When Using SVN And Contao 3.1.0
If you are using Contao 3.1.0 and you are experiencing some trouble in developing your module, this is probably due to a system bug. Contao 3.1.0 release does not read Subversion files (also known as cache files .svn). This should not stop you from using the latest Contao release as this bug is no longer an issue with 3.1.1 users.