PHPackages                             phix/contractlib - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phix/contractlib

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phix/contractlib
================

ContractLib is a lightweight PHP library designed to help you write more robust PHP components by helping your components enforce programming contracts throughout your code

2.1.4(12y ago)3233.8k↓50%22BSD-3-ClausePHP

Since Jun 8Pushed 12y ago4 watchersCompare

[ Source](https://github.com/stuartherbert/ContractLib)[ Packagist](https://packagist.org/packages/phix/contractlib)[ Docs](https://github.com/stuartherbert/ContractLib/)[ RSS](/packages/phix-contractlib/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (2)

ContractLib
===========

[](#contractlib)

**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](http://research.microsoft.com/en-us/projects/contracts/userdoc.pdf)

System-Wide Installation
------------------------

[](#system-wide-installation)

ContractLib should be installed using the [PEAR Installer](http://pear.php.net). This installer is the PHP community's de-facto standard for installing PHP components.

```
sudo pear channel-discover pear.phix-project.org
sudo pear install --alldeps phix/ContractLib

```

As A Dependency On Your Component
---------------------------------

[](#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:

```

      ContractLib
      pear.phix-project.org
      1.0.0
      1.999.9999

```

Usage
-----

[](#usage)

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
-----------------------

[](#development-environment)

If you want to patch or enhance this component, you will need to create a suitable development environment, by [installing phix](http://phix-project.org#install).

You can then clone the git repository:

```
# ContractLib
git clone git@github.com:stuartherbert/ContractLib.git

```

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](http://phing.info). 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.

License
-------

[](#license)

See LICENSE.txt for full license details.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4726d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2dc3934d5c3ce55e18dca95d52b564fb2a34986770af3c532dba6c248ef58f3a?d=identicon)[stuartherbert](/maintainers/stuartherbert)

---

Top Contributors

[![stuartherbert](https://avatars.githubusercontent.com/u/7926?v=4)](https://github.com/stuartherbert "stuartherbert (50 commits)")

### Embed Badge

![Health badge](/badges/phix-contractlib/health.svg)

```
[![Health](https://phpackages.com/badges/phix-contractlib/health.svg)](https://phpackages.com/packages/phix-contractlib)
```

###  Alternatives

[f9webltd/laravel-redirect-response-macros

Some useful redirect response macros for your Laravel application

212.3k](/packages/f9webltd-laravel-redirect-response-macros)[algoyounes/laravel-package-skeleton

Laravel Package Skeleton for streamlined package development

271.3k](/packages/algoyounes-laravel-package-skeleton)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
