Developer's Reference
This page is for those interested in getting their hands dirty in Zenphoto's code. It's currently under construction. I'll add to it little by little as I can.
- Zenphoto Development
- Working with the Codebase
- Classes
- Functions and Theme Functions
- EXIF Library
- Help Wanted
Zenphoto Development
The following pages are brainstorms, ideas, specs, and general storage for documents about Zenphoto's core development.
- ZenphotoDevPlugins - Tracking the development of plugins for Zenphoto.
- ZenphotoDevIdeas? - for new ideas.
- ZenphotoDevSpecs? - for specification of new features or code.
- ZenphotoDevModel - for discussion and ideas of restructuring the object model.
- ZenphotoDevAdmin? - for ideas and design of the admin UI and functionality.
Working with the Codebase
Style
Zenphoto code follows some basic Style guidelines. We essentially use K&R notation C-code syntax, for example:
function foo($bar) {
if ($bar == 2) {
return $bar;
} else if ($bar < 2) {
while($bar < 2) {
echo $bar;
$bar++;
}
}
}
This is a fairly standard formatting for PHP code and makes things nice and readable.
A few rules:
- Spaces should be used liberally. Eg: if($x == 2 || $y == 3) and not if($x==2||$y==3).
- Indentation should be hard tabs, not space-emulated tabs.
- Always use variable and function names that make sense and are self explanatory. Eg: $album_name and not $n
- $underscored_variable_names are preferred.
- camelCaseFunctionNames() are preferred.
And a few guidelines for coding in general that we encourage:
- Use generalization and abstraction. DRY! (Don't repeat yourself).
- Keep it simple - if something seems too complex it probably is.
- Keep efficiency in mind - try not to put filesystem operations in nested loops, for example.
- Write clean code! Make things readable and understandable.
Commenting and Documentation
Zenphoto uses PHPDoc to generate function and class documentation. This works well because the documentation is both in-line with the code, and browsable externally as a reference.
Zenphoto's PHPDoc reference is on the main zenphoto.org site.
Instructions for how to form comments for functions and variables can be found on PHPDoc's site here. Or take a look at Zenphoto's code for examples.
Nightly Builds
If you would like to simply test the development releases of Zenphoto between releases, you can use a nightly build. These are created from the current SVN trunk every 23:00 Pacific Standard Time.
The nightly builds are located at: http://www.zenphoto.org/files/nightly
Warning: These packages are unstable and haven't necessarily been tested. Use them only if you wish to help test new features and give us feedback.
Subversion
Zenphoto uses Subversion for revision control, and we like it a lot. You can browse the repository by using the Trac source code browser, which is very useful for seeing diffs and revisions in real time.
The SVN repository is located at: http://www.zenphoto.org/svn
And the repository structure is fairly standard:
- /trunk is the current version in development, where we do most of our work.
- /branches are versions with less stable code in heavy development, which may be later merged into trunk.
- /tags are snapshots of the trunk at any given time, usually all version releases, or pre-merge from a branch.
If you want the "Latest SVN Code" to work with, you should "check out" the repository locally by running:
svn checkout http://www.zenphoto.org/svn/trunk
If you just want to run the latest code without all the SVN metadata files, you should do an export:
svn export http://www.zenphoto.org/svn/trunk zenphoto/
And finally, if you're going to be working with the SVN copy a lot, you should get a good SVN client for your operating system. On Windows, TortoiseSVN works great.
Classes
Specific descriptions and reference material about each Zenphoto class. Zenphoto uses a custom-designed persistence model based on logical object orientation, so all of its classes make sense in the model.
Functions and Theme Functions
The Zenphoto Function Reference can be found on the zenphoto.org home page and is the main source for documentation on core functions and theme functions.
EXIF Library
Zenphoto uses and has adopted development of the Exifixer library by Jake Olefsky. We are currently at version 1.7 of this library and it is under the GPL license like the rest of zenphoto and is available for any other use. We have a Wiki page for it at ExifixerLibrary with a download link if you would like to download the library independently of the Zenphoto software.
Help Wanted
We're always looking for more developers to help make the project better. If you're interested in helping out, check out the Trunk source tree from the SVN repository and start familiarizing yourself with the code. As with most open-source projects, the best way to get your foot in the door is to check in patches or code for issues on the bugtracker. Also feel free to ask on the forums for something to do if you don't have anything specific in mind.
