PHPackages                             tcopestake/w3capi - 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. [API Development](/categories/api)
4. /
5. tcopestake/w3capi

ActiveLibrary[API Development](/categories/api)

tcopestake/w3capi
=================

A PHP wrapper/client for the W3C validator API

v1.0.0(12y ago)1311PHPPHP &gt;=5.3.0

Since Jul 7Pushed 12y ago1 watchersCompare

[ Source](https://github.com/tcopestake/w3capi)[ Packagist](https://packagist.org/packages/tcopestake/w3capi)[ RSS](/packages/tcopestake-w3capi/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

w3capi
======

[](#w3capi)

A PHP wrapper/client for the W3C validator API

Quick disclaimer
----------------

[](#quick-disclaimer)

I'm unsure how stable the actual W3C API is, as it's documented as experimental and subject to change; don't be surprised if things stop working. You can read more at

Pay special attention to this notice:

> If you wish to call the validator programmatically for a batch of documents, please make sure that your script will sleep for **at least 1 second** between requests. The Markup Validation service is a free, public service for all, your respect is appreciated. thanks.

When making multiple calls through a validator instance, this will be done for you (see below).

Requirements:
-------------

[](#requirements)

- PHP 5.3+
- \* cURL
- \* SimpleXML

\* Can be abstracted away by providing alternative interfaces

Installation
------------

[](#installation)

This package can be installed manually or via Composer.

### Composer

[](#composer)

Add the following to your project's composer.json:

```
"repositories": [
    {
        "type": "vcs",
        "url":  "https://github.com/tcopestake/w3capi"
    }
],

```

and:

```
"require": {
    "tcopestake/w3capi": "*"
},

```

### Manual

[](#manual)

Download and extract the files.

If your project doesn't already have a suitable autoloader, you can use the one provided by including src/bootstrap.php:

```
include('path/to/src/bootstrap.php');

```

Usage
-----

[](#usage)

### The validator

[](#the-validator)

To validate a document:

```
$validator = new \W3CAPI\Validator;

try {
    $validator->validate('http://url.test.com/a-html-page');
} catch(\W3CAPI\Exceptions\SoapClientBadResponse $e) {
    echo "Most likely, W3C reported a server error.";
} catch(\W3CAPI\ValidatorUnknownError $e) {
    echo "Something went wrong, but we don't know what.";
}

```

If successful, information can then be retrieved from the instance, such as whether the document passed validation:

```
echo ($validator->isValid()) ? 'Valid' : 'Invalid';

```

and information about semantic validation errors:

```
if($validator->getErrorCount() > 0) {
    foreach($validator->getErrors() as $error) {
        /*
         * $error will be an array
         * containing the error message, etc.
         *
         */
    }
}

```

and information about validation warnings:

```
if($validator->getWarningCount() > 0) {
    foreach($validator->getWarnings() as $warning) {
        /*
         * $warning will be an array
         * containing the warning message, etc.
         *
         */
    }
}

```

If you wish to validate another document, the validator instance can be easily reused:

```
try {
    $validator->validate('http://another.url.com/shame.css');
} catch(\W3CAPI\Exceptions\SoapClientBadResponse $e) {
    echo "Most likely, W3C reported a server error.";
} catch(\W3CAPI\ValidatorUnknownError $e) {
    echo "Something went wrong, but we don't know what.";
}

```

Note that when making subsequent calls, the validator class will enforce W3C's "1 second" rule by delaying sending the request if necessary.

Tests
-----

[](#tests)

There are unit tests.

Possible developments(?)
------------------------

[](#possible-developments)

- Support for validating documents via POST upload.
- More documentation (esp. on dependency injection).
- Revisit the XML parser.
- More transparency between classes e.g. ability to retrieve HTTP headers
- Peer pressure is forcing me to switch to PSR-2, but my muscle memory forgets this sometimes.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

4693d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b15461d1c72035566fa4224e8b8dcafec816c1c6cfd74b994eacb18d03b131da?d=identicon)[tcopestake](/maintainers/tcopestake)

### Embed Badge

![Health badge](/badges/tcopestake-w3capi/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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