Download the PHP package tcopestake/w3capi without Composer

On this page you can find all versions of the php package tcopestake/w3capi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package w3capi

w3capi

A PHP wrapper/client for the W3C validator API

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 http://validator.w3.org/docs/api.html

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:

* Can be abstracted away by providing alternative interfaces

Installation

This package can be installed manually or via 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

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

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

There are unit tests.

Possible developments(?)


All versions of w3capi with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tcopestake/w3capi contains the following files

Loading the files please wait ....