Difference between revisions of "Information for Developers"

From PKP Wiki
Jump to: navigation, search
m (Removing redundant text, hope that's OK)
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Bugzilla =
+
= Managing Contributions =
 +
 
 +
PKP code development, including external contributions, is managed between [http://pkp.sfu.ca/bugzilla Bugzilla] and [https://github.com/pkp/ Github]. We prefer that issues be opened as either bugs or feature requests in Bugzilla, and that fixes are submitted as pull requests via Github, but we do still accept patches uploaded to Bugzilla itself if you do not want to submit via Github pull request.
 +
 
 +
= Identifying an Issue =
  
 
You can access our Bugzilla database [http://pkp.sfu.ca/bugzilla here]. We welcome any bug reports and feature requests, so long as they are understandably written and flagged correctly (mostly an issue of setting the severity between enhancement; trivial; minor; normal; major; critical; or blocker levels, although you can also set the priority as well if you'd like). You can see a great set of bug-writing guidelines [http://pkp.sfu.ca/bugzilla/page.cgi?id=bug-writing.html here].  
 
You can access our Bugzilla database [http://pkp.sfu.ca/bugzilla here]. We welcome any bug reports and feature requests, so long as they are understandably written and flagged correctly (mostly an issue of setting the severity between enhancement; trivial; minor; normal; major; critical; or blocker levels, although you can also set the priority as well if you'd like). You can see a great set of bug-writing guidelines [http://pkp.sfu.ca/bugzilla/page.cgi?id=bug-writing.html here].  
Line 5: Line 9:
 
You are also advised to [http://pkp.sfu.ca/bugzilla/query.cgi search] for similar reports to avoid duplication.  
 
You are also advised to [http://pkp.sfu.ca/bugzilla/query.cgi search] for similar reports to avoid duplication.  
  
= CVS Access =
+
= Contributing Code =
  
== Web-based CVS ==  
+
== Contributing via Github ==
  
You can browse our CVS repository online [http://pkp.sfu.ca/cvs/cvsweb.cgi/#dirlist here].  
+
Contributing code via Github is our '''preferred method'''. Please see http://pkp.sfu.ca/wiki/index.php/HOW-TO_check_out_PKP_applications_from_git and http://pkp.sfu.ca/wiki/index.php/Frequent_git_use_cases for extensive instructions on the ins and outs of working with git repositories.
  
== Command Line CVS access ==
+
To contribute code back to us, feel free to submit a pull request from git.
  
(This is not a guide on how to use CVS. For more CVS information, try [http://www.nongnu.org/cvs/ here], [http://www.eyrie.org/~eagle/notes/cvs/basic-usage.html here], and [http://en.wikipedia.org/wiki/Concurrent_Versions_System here].
+
If you are working against a particular entry in our Bugzilla database, use the following format for commit messages:
  
You can check out all CVS modules via anonymous CVS. Before you do so, you should know which modules, exactly, you want to work with. OJS and OCS each have a stable and devel branch; the stable branches are standalone maintenance releases (extensions of OJS 2.2.2 and OCS 2.1.1 codebases), while the devel branches also requires the PKP Web Application Library (WAL) be checked out and installed in the lib/ directory. Harvester2 and Open Monograph Press only have one devel branch, and each require the PKP WAL. Lemon8 is a standalone program with only one branch at the moment.
+
    *1234* My Commit Description
  
=== Setting up the Environment ===
+
...where the 1234 is the bug ID from Bugzilla. This allows Bugzilla to track back to the commits made in that entry and helps us assemble release notes consistently.
  
The following instructions are more or less directly applicable to any *nix operating systems (OS X incl.); Windows users probably need to do things a little differently. Also, these are general instructions, pertaining to how I manage my own setup -- you might want to do things a little bit differently.
+
== Contributing Patches ==
  
Firstly, create a CVS directory to store all your cvs checkouts in. I created mine in /Users/jmacgreg/ and then entered into the new directory, from which I ran the remaining commands:  
+
If you cannot or do not want to contribute via Github, you can upload patches directly to bug reports. We're always happy to receive patches, whether for contribution to a project or for general community availability on [http://pkp.sfu.ca/support/forum the forums]. The one thing we do ask is that you provide the patch in [http://en.wikipedia.org/wiki/Diff#Unified_format Unified Diff] format. If you are using our [http://pkp.sfu.ca/wiki/index.php/Main_Page#Development_Topics git instructions] to work with the application codebase (highly recommended), you can create unified diffs via git using the following command:  
  
  mkdir /Users/jmacgreg/cvs
+
  git diff -u ./ > patch.diff
cd cvs
+
  
You'll then have to log into our CVS repository using our anonymous credentials:
+
... which will find all differences in the working directory and '''recursively''', and write them to a file called patch.diff.
  
cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs login
 
  
You will be asked for a password — there is none, so just hit enter. After which you should be able to run the following commands to grab specific modules.
+
== Applying Patches ==
  
=== OJS and OCS '''stable''' branches ===
+
=== Patching Manually ===
  
To grab the OCS and OJS stable branches, run the following commands:
+
If you want to apply a patch manually, whether from Bugzilla or from Github, download it to your development environment, and from the application's root directory and run  
  
  cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d ojs2-stable -r ojs2-branch-2_2_2 ojs2
+
  patch -p0 < ./path/to/patch.diff
  
The above command will download the current code for the OJS 2.2.2 branch of the ojs2 module, and deposit in a new 'ojs2-stable' directory in the directory you are currently in (you moved to your cvs/ directory, right?)
+
The --dry-run option to the patch tool allows you to safely test the patch to see if it will apply cleanly, and if not, where the conflicts will arise.
  
cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d ocs2-stable -r ocs2-branch-2_1_1 ocs2
+
For more Windows (and general) information, also see [http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=3779 this forum thread].
  
The above command will download the OCS 2.1.1 code into ocs2-stable/.
+
=== Patching from Github ===
  
Setting this up to be served by Apache is up to you (I have it symlinked to my web folder). Remember, while this branch is still fairly stable in comparison to the heavily modified devel branch, it's still a work in progress and shouldn't be used in a production environment unless you know what you're doing.
+
You can grab "patches" from Github by finding that particular commit's has and cherry-picking it:
  
=== Lemon8-XML ===
+
First, find the hash for the commit you want to apply locally. The hash is the last string in the commit's URL, for example for the commit found at https://github.com/pkp/ojs/commit/4aba081d35133c1ee9a9e1f3b9166ca5db5fd48d it would be "4aba081d35133c1ee9a9e1f3b9166ca5db5fd48d".
  
To checkout the most recent Lemon8 code, run
+
Next, make sure your local repository is up to date (NB that this does not automatically merge all new remote commits to your repository, it [http://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch just stores them locally]):
  
  cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d lemon8-xml lemon8-xml
+
  git fetch
  
The above command will download the latest Lemon8 development code into a new lemon8-xml directory.
+
Then, cherry-pick the commit you want to apply by hash:
  
=== Development Branches ===
+
git cherry-pick 4aba081d35133c1ee9a9e1f3b9166ca5db5fd48d
  
OJS and OCS development branches, as well as the only Harvester2 and OMP (and de facto development) branches, all work a little differently: they all rely on the PKP WAL module as a dependency. The WAL module needs to be 'installed' (symlinking is fine) in each branches' lib/ directory.
+
= Setting up a flexible development environment =
  
First, checkout the packages you need:  
+
NB: This is not a beginner's installation/configuration tutorial. We only highlight a few important differences from a standard installation as a help for experienced PKP, database, PHP and web server users.
  
'''OJS devel''' (2.3):
+
== Install and Configure Databases ==
  
cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d ojs2-devel ojs2
+
* There is nothing special to the database installation. Use your OS' standard installation procedure to install the necessary databases you want to test in parallel.
 +
* Edit config.inc.php to switch the database connection.
  
 +
== Install and Configure supported PHP versions ==
  
'''Harvester devel''' (2.3):
+
* Download or build the PHP binaries you want to test (newer versions can be downloaded from php.net or are part of the standard OS distributions, older versions must be built from source).
 +
* You'll need the thread-safe version if you want to test mod_php in Apache.
 +
* Install all binaries and configuration separately. Do not create any shared files or configuration (separate php.ini, separate installation directories).
 +
* On Windows:
 +
** Get the PHP zip arquive distributions where available and unzip them into separate folders.
 +
** [http://sourceforge.net/projects/xampp/files/ XAMPP] has lots of old Windows binaries if the version you look for is no longer officially supported on php.net.
 +
** Download the thread-safe VC6 version as VC9 versions are not compatible with Apache.
 +
** Do '''not''' install DLL files in C:\WINDOWS or any other directory on the path.
 +
** Do '''not''' install any registry keys.
 +
** Do '''not''' configure any shared environment variables.
 +
* Exception: Install PEAR in a central folder that is accessible by all PHP versions. Install necessary PEAR dependencies (e.g. PHPUnit, etc.) - see separate documentation on this Wiki for that.
 +
* Edit the development php.ini files as required:
 +
** extension_dir must point to the absolute path of the version specific extension binaries
 +
** enable extensions required by PKP software (e.g. database client, GD, etc.)
 +
** optional: error_reporting, display_errors, log_errors, error_log, max_execution_time, xdebug
 +
* Test all PHP installations separately: /path/to/php -c /path/to/php.ini -v (This should discover most problems with wrong extension paths).
  
cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d harvester2 harvester2
+
== Install and Configure Apache ==
  
 +
We use Apache so that we can test CGI, FCGI and Module configurations in parallel. Install Apache 2.2 (standard distribution for your OS). Then get and install [http://httpd.apache.org/mod_fcgid/ mod_fcgid] as explained on the linked web pages.
  
'''OMP devel''' (2.3):
+
All the magic lies in Apache's httpd.conf. Here's the Windows version. It should be easy to adapt that to your specific OS:
  
  cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d omp omp
+
  ...
  
 +
#General CGI Support
 +
<IfDefine CGI>
 +
    LoadModule cgi_module modules/mod_cgi.so
 +
    AddHandler application/x-httpd-php .php
 +
</IfDefine>
  
Now the tricky part. You need to download the PKP WAL (called 'pkp' in CVS) and either copy it or [http://en.wikipedia.org/wiki/Symbolic_link symlink] it to your devel instances' lib/ directory. I prefer symlinking, as I can do this for each devel instance I'm running, and only have to remember to update one directory.
+
#General FCGI Support
 +
<IfDefine FCGI>
 +
    LoadModule fcgid_module modules/mod_fcgid.so
 +
    AddHandler fcgid-script .php
 +
    <Directory "C:/path/to/your/pkp/doc/root">
 +
        Options +ExecCGI
 +
    </Directory>
 +
</IfDefine>
  
Checkout the pkp module:  
+
#PHP 4.3 support
 +
<IfDefine PHP43>
 +
    <IfDefine CGI>
 +
        Action application/x-httpd-php "/php-cgi/php.exe"
 +
        ScriptAlias /php-cgi/ "C:/path/to/php43/"
 +
        <Directory "C:/path/to/php43">
 +
            Order allow,deny
 +
            Allow from 127.0.0.1
 +
        </Directory>
 +
    </IfDefine>
 +
</IfDefine>
  
  cvs -d :pserver:anonymous@lib-pkp.lib.sfu.ca:/cvs checkout -d pkp pkp
+
  #PHP 5.2 support
 +
<IfDefine PHP52>
 +
    <IfDefine MODULE>
 +
        LoadFile "C:/path/to/php52/php5ts.dll"
 +
        LoadFile "C:/path/to/php52/libmysql.dll" # This is required (PHP52 only) otherwise PHP might load libmysql.dll from MySQL's own bin
 +
        LoadModule php5_module "C:/path/to/php52/php5apache2_2.dll"
 +
        PHPIniDir "C:/path/to/php52"
 +
    </IfDefine>
  
Symlink the module to eg. OJS' lib/ directory:
+
    <IfDefine FCGI>
 +
        FcgidWrapper "C:/path/to/php52/php-cgi.exe" .php
 +
    </IfDefine>
  
ln -s /Users/jmacgreg/cvs/pkp /Users/jmacgreg/cvs/ojs2-devel/lib/pkp
+
    <IfDefine CGI>
 +
        Action application/x-httpd-php "/php-cgi/php-cgi.exe"
 +
        ScriptAlias /php-cgi/ "C:/path/to/php52/"
 +
        <Directory "C:/path/to/php52">
 +
            Order allow,deny
 +
            Allow from 127.0.0.1
 +
        </Directory>
 +
    </IfDefine>
 +
</IfDefine>
  
... and repeat as necessary for each application.
+
#PHP 5.3 support
 +
<IfDefine PHP53>
 +
    <IfDefine MODULE>
 +
        LoadFile "C:/path/to/php53/php5ts.dll"
 +
        LoadModule php5_module "C:/path/to/php53/php5apache2_2.dll"
 +
        PHPIniDir "C:/path/to/php53"
 +
    </IfDefine>
  
= Patches =
+
    <IfDefine FCGI>
 +
        FcgidWrapper "C:/path/to/php53/php-cgi.exe" .php
 +
    </IfDefine>
  
== Making Patches ==
+
    <IfDefine CGI>
 +
        Action application/x-httpd-php "/php-cgi/php-cgi.exe"
 +
        ScriptAlias /php-cgi/ "C:/path/to/php53/"
 +
        <Directory "C:/path/to/php53">
 +
            Order allow,deny
 +
            Allow from 127.0.0.1
 +
        </Directory>
 +
    </IfDefine>
 +
</IfDefine>
  
We're always happy to receive patches, whether for contribution to a project or for general community availability on [http://pkp.sfu.ca/support/forum the forums]. The one thing we do ask is that you provide the patch in [http://en.wikipedia.org/wiki/Diff#Unified_format Unified Diff] format. If you are patching against one of the above CVS modules, the easiest thing to do is generate your patch using something like the following command (which will generate a diff of the entire directory you are currently in, for example ojs2-devel, against the entire cvs module):
+
DocumentRoot "C:/path/to/your/pkp/doc/root"
  
  cvs diff -uN ./ > patch.diff
+
  <Directory "C:/path/to/your/pkp/doc/root">
 +
    Options +FollowSymLinks
 +
    AllowOverride All
 +
    Order allow,deny
 +
    Allow from all
 +
</Directory>
  
=== Applying Patches ===
+
...
  
If you want to apply a patch, download it to your development environment, and from the application's root directory and run
+
Now all you need to switch configurations is starting Apache like this:
 +
http -D(PHP43|PHP52|PHP53) -D(MODULE|CGI|FCGI)
  
  patch -p0 < ./path/to/patch.diff
+
A few examples:
 
+
  http -DPHP43 -DCGI
The --dry-run option to the patch tool allows you to safely test the patch to see if it will apply cleanly, and if not, where the conflicts will arise.
+
http -DPHP52 -DMODULE
 
+
http -DPHP53 -DFCGI
For more Windows (and general) information, also see [http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=3779 this forum thread].
+

Revision as of 13:45, 13 May 2013

Managing Contributions

PKP code development, including external contributions, is managed between Bugzilla and Github. We prefer that issues be opened as either bugs or feature requests in Bugzilla, and that fixes are submitted as pull requests via Github, but we do still accept patches uploaded to Bugzilla itself if you do not want to submit via Github pull request.

Identifying an Issue

You can access our Bugzilla database here. We welcome any bug reports and feature requests, so long as they are understandably written and flagged correctly (mostly an issue of setting the severity between enhancement; trivial; minor; normal; major; critical; or blocker levels, although you can also set the priority as well if you'd like). You can see a great set of bug-writing guidelines here.

You are also advised to search for similar reports to avoid duplication.

Contributing Code

Contributing via Github

Contributing code via Github is our preferred method. Please see http://pkp.sfu.ca/wiki/index.php/HOW-TO_check_out_PKP_applications_from_git and http://pkp.sfu.ca/wiki/index.php/Frequent_git_use_cases for extensive instructions on the ins and outs of working with git repositories.

To contribute code back to us, feel free to submit a pull request from git.

If you are working against a particular entry in our Bugzilla database, use the following format for commit messages:

   *1234* My Commit Description

...where the 1234 is the bug ID from Bugzilla. This allows Bugzilla to track back to the commits made in that entry and helps us assemble release notes consistently.

Contributing Patches

If you cannot or do not want to contribute via Github, you can upload patches directly to bug reports. We're always happy to receive patches, whether for contribution to a project or for general community availability on the forums. The one thing we do ask is that you provide the patch in Unified Diff format. If you are using our git instructions to work with the application codebase (highly recommended), you can create unified diffs via git using the following command:

git diff -u ./ > patch.diff

... which will find all differences in the working directory and recursively, and write them to a file called patch.diff.


Applying Patches

Patching Manually

If you want to apply a patch manually, whether from Bugzilla or from Github, download it to your development environment, and from the application's root directory and run

patch -p0 < ./path/to/patch.diff

The --dry-run option to the patch tool allows you to safely test the patch to see if it will apply cleanly, and if not, where the conflicts will arise.

For more Windows (and general) information, also see this forum thread.

Patching from Github

You can grab "patches" from Github by finding that particular commit's has and cherry-picking it:

First, find the hash for the commit you want to apply locally. The hash is the last string in the commit's URL, for example for the commit found at https://github.com/pkp/ojs/commit/4aba081d35133c1ee9a9e1f3b9166ca5db5fd48d it would be "4aba081d35133c1ee9a9e1f3b9166ca5db5fd48d".

Next, make sure your local repository is up to date (NB that this does not automatically merge all new remote commits to your repository, it just stores them locally):

git fetch 

Then, cherry-pick the commit you want to apply by hash:

git cherry-pick 4aba081d35133c1ee9a9e1f3b9166ca5db5fd48d

Setting up a flexible development environment

NB: This is not a beginner's installation/configuration tutorial. We only highlight a few important differences from a standard installation as a help for experienced PKP, database, PHP and web server users.

Install and Configure Databases

  • There is nothing special to the database installation. Use your OS' standard installation procedure to install the necessary databases you want to test in parallel.
  • Edit config.inc.php to switch the database connection.

Install and Configure supported PHP versions

  • Download or build the PHP binaries you want to test (newer versions can be downloaded from php.net or are part of the standard OS distributions, older versions must be built from source).
  • You'll need the thread-safe version if you want to test mod_php in Apache.
  • Install all binaries and configuration separately. Do not create any shared files or configuration (separate php.ini, separate installation directories).
  • On Windows:
    • Get the PHP zip arquive distributions where available and unzip them into separate folders.
    • XAMPP has lots of old Windows binaries if the version you look for is no longer officially supported on php.net.
    • Download the thread-safe VC6 version as VC9 versions are not compatible with Apache.
    • Do not install DLL files in C:\WINDOWS or any other directory on the path.
    • Do not install any registry keys.
    • Do not configure any shared environment variables.
  • Exception: Install PEAR in a central folder that is accessible by all PHP versions. Install necessary PEAR dependencies (e.g. PHPUnit, etc.) - see separate documentation on this Wiki for that.
  • Edit the development php.ini files as required:
    • extension_dir must point to the absolute path of the version specific extension binaries
    • enable extensions required by PKP software (e.g. database client, GD, etc.)
    • optional: error_reporting, display_errors, log_errors, error_log, max_execution_time, xdebug
  • Test all PHP installations separately: /path/to/php -c /path/to/php.ini -v (This should discover most problems with wrong extension paths).

Install and Configure Apache

We use Apache so that we can test CGI, FCGI and Module configurations in parallel. Install Apache 2.2 (standard distribution for your OS). Then get and install mod_fcgid as explained on the linked web pages.

All the magic lies in Apache's httpd.conf. Here's the Windows version. It should be easy to adapt that to your specific OS:

...
#General CGI Support
<IfDefine CGI>
    LoadModule cgi_module modules/mod_cgi.so
    AddHandler application/x-httpd-php .php
</IfDefine>
#General FCGI Support
<IfDefine FCGI>
    LoadModule fcgid_module modules/mod_fcgid.so
    AddHandler fcgid-script .php
    <Directory "C:/path/to/your/pkp/doc/root">
        Options +ExecCGI
    </Directory>
</IfDefine>
#PHP 4.3 support
<IfDefine PHP43>
    <IfDefine CGI>
        Action application/x-httpd-php "/php-cgi/php.exe"
        ScriptAlias /php-cgi/ "C:/path/to/php43/"
        <Directory "C:/path/to/php43">
            Order allow,deny
            Allow from 127.0.0.1
        </Directory>
    </IfDefine>
</IfDefine>
#PHP 5.2 support
<IfDefine PHP52>
    <IfDefine MODULE>
        LoadFile "C:/path/to/php52/php5ts.dll"
        LoadFile "C:/path/to/php52/libmysql.dll" # This is required (PHP52 only) otherwise PHP might load libmysql.dll from MySQL's own bin
        LoadModule php5_module "C:/path/to/php52/php5apache2_2.dll"
        PHPIniDir "C:/path/to/php52"
    </IfDefine>
    <IfDefine FCGI>
        FcgidWrapper "C:/path/to/php52/php-cgi.exe" .php
    </IfDefine>
    <IfDefine CGI>
        Action application/x-httpd-php "/php-cgi/php-cgi.exe"
        ScriptAlias /php-cgi/ "C:/path/to/php52/"
        <Directory "C:/path/to/php52">
            Order allow,deny
            Allow from 127.0.0.1
        </Directory>
    </IfDefine>
</IfDefine>
#PHP 5.3 support
<IfDefine PHP53>
    <IfDefine MODULE>
        LoadFile "C:/path/to/php53/php5ts.dll"
        LoadModule php5_module "C:/path/to/php53/php5apache2_2.dll"
        PHPIniDir "C:/path/to/php53"
    </IfDefine>
    <IfDefine FCGI>
        FcgidWrapper "C:/path/to/php53/php-cgi.exe" .php
    </IfDefine>
    <IfDefine CGI>
        Action application/x-httpd-php "/php-cgi/php-cgi.exe"
        ScriptAlias /php-cgi/ "C:/path/to/php53/"
        <Directory "C:/path/to/php53">
            Order allow,deny
            Allow from 127.0.0.1
        </Directory>
    </IfDefine>
</IfDefine>
DocumentRoot "C:/path/to/your/pkp/doc/root"
<Directory "C:/path/to/your/pkp/doc/root">
    Options +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
...

Now all you need to switch configurations is starting Apache like this:

http -D(PHP43|PHP52|PHP53) -D(MODULE|CGI|FCGI)

A few examples:

http -DPHP43 -DCGI
http -DPHP52 -DMODULE
http -DPHP53 -DFCGI