Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple Design By Contract library for PHP components
branch: develop

Merge tag '2.1.4' into develop

- Fix: give up on versioned names for Composer packages
- Fix: stop breaking PHPUnit
Failed to load latest commit information.
src Fixes: give up on versioned names for Composer packages; stop breakin…
.gitignore New: ignore the composer.phar file
.hgignore Initial commit
.travis.yml Fix: install dev dependencies for Travis CI
LICENSE.txt Initial commit Fix markup in README file
build.local.xml Upgraded skeleton files
build.xml Upgraded to latest skeleton
composer.json Fixes: give up on versioned names for Composer packages; stop breakin…
package.xml Now uses Autoloader4 and ExceptionsLib1
phpunit.xml Initial commit


ContractLib is a simple-to-use PHP component for easily enforcing programming contracts throughout your PHP components. These programming contracts can go a long way to helping you, and the users of your components, develop more robust code.

ContractLib is loosely inspired by Microsoft Research's work on the Code Contracts Library for .NET

System-Wide Installation

ContractLib should be installed using the PEAR Installer. This installer is the PHP community's de-facto standard for installing PHP components.

sudo pear channel-discover
sudo pear install --alldeps phix/ContractLib

As A Dependency On Your Component

If you are creating a component that relies on ContractLib, please make sure that you add LicenseLib to your component's package.xml file:



The best documentation for ContractLib are the unit tests, which are shipped in the package. You will find them installed into your PEAR repository, which on Linux systems is normally /usr/share/php/test.

You can find them online on GitHub:

Development Environment

If you want to patch or enhance this component, you will need to create a suitable development environment, by installing phix.

You can then clone the git repository:

# ContractLib
git clone

Then, install a local copy of this component's dependencies to complete the development environment:

# build vendor/ folder
phing build-vendor

To make life easier for you, common tasks (such as running unit tests, generating code review analytics, and creating the PEAR package) have been automated using phing. You'll find the automated steps inside the build.xml file that ships with the component.

Run the command 'phing' in the component's top-level folder to see the full list of available automated tasks.


See LICENSE.txt for full license details.

Something went wrong with that request. Please try again.