Download the PHP package p3k/xray without Composer

On this page you can find all versions of the php package p3k/xray. 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 xray

XRay

XRay parses structured content from a URL.

Discovering Content

XRay will parse content in the following formats. First the URL is checked against known services:

If the contents of the URL is XML or JSON, then XRay will parse the Atom, RSS or JSONFeed formats.

Finally, XRay looks for Microformats on the page and will determine the content from that.

Library

XRay can be used as a library in your PHP project. The easiest way to install it and its dependencies is via composer.

You can also download a release which is a zip file with all dependencies already installed.

Parsing

If you already have an HTML or JSON document you want to parse, you can pass it as a string in the second parameter.

In both cases, you can add an additional parameter to configure various options of how XRay will behave. Below is a list of the options.

Additional parameters are supported when making requests that use the GitHub API. See the Authentication section below for details.

The XRay constructor can optionally be passed an array of default options, which will be applied in addition to (and can be overridden by) the options passed to individual parse() calls.

The $parsed return value will look like the below. See "Primary Data" below for an explanation of the vocabularies returned.

Processing Microformats2 JSON

If you already have a parsed Microformats2 document as an array, you can use a special function to process it into XRay's native format. Make sure you pass the entire parsed document, not just the single item.

Rels

You can also use XRay to fetch all the rel values on a page, merging the list of HTTP Link headers with rel values with the HTML rel values on the page.

This will return a similar response to the parser, but instead of a data key containing the parsed page, there will be rels, an associative array. Each key will contain an array of all the values that match that rel value.

Feed Discovery

You can use XRay to discover the types of feeds available at a URL.

This will fetch the URL, check for a Microformats feed, as well as check for rel=alternates pointing to Atom, RSS or JSONFeed URLs. The response will look like the below.

Customizing the User Agent

To set a unique user agent, (some websites will require a user agent be set), you can set the http property of the object to a p3k\HTTP object.

API

XRay can also be used as an API to provide its parsing capabilities over an HTTP service.

To parse a page and return structured data for the contents of the page, simply pass a url to the /parse route.

To conditionally parse the page after first checking if it contains a link to a target URL, also include the target URL as a parameter. This is useful when using XRay to verify an incoming webmention.

In both cases, the response will be a JSON object containing a key of "type". If there was an error, "type" will be set to the string "error", otherwise it will refer to the kind of content that was found at the URL, most often "entry".

You can also make a POST request with the same parameter names.

If you already have an HTML or JSON document you want to parse, you can include that in the POST parameter body. This POST request would look like the below:

or for GitHub where you might have JSON,

Parameters

XRay accepts the following parameters when calling /parse

Authentication

If the URL you are fetching requires authentication, include the access token in the parameter "token", and it will be included in an "Authorization" header when fetching the URL. (It is recommended to use a POST request in this case, to avoid the access token potentially being logged as part of the query string.) This is useful for Private Webmention verification.

API Authentication

XRay uses the Github APIs to fetch posts, and those API require authentication. In order to keep XRay stateless, it is required that you pass in the credentials to the parse call.

You should only send the credentials when the URL you are trying to parse is a GitHub URL, so you'll want to check for whether the hostname is github.com, etc. before you include credentials in this call.

GitHub Authentication

XRay uses the GitHub API to fetch GitHub URLs, which provides higher rate limits when used with authentication. You can pass a GitHub access token along with the request and XRay will use it when making requests to the API.

Error Response

Possible errors are listed below:

Response Format

Primary Data

The primary object on the page is returned in the data property. This will indicate the type of object (e.g. entry), and will contain the vocabulary's properties that it was able to parse from the page.

If a property supports multiple values, it will always be returned as an array. The following properties support multiple values:

The content will be an object that always contains a "text" property and may contain an "html" property if the source documented published HTML content. The "text" property must always be HTML escaped before displaying it as HTML, as it may include unescaped characters such as < and >.

The author will always be set in the entry if available. The service follows the authorship discovery algorithm to try to find the author information elsewhere on the page if it is not inside the entry in the source document.

All URLs provided in the output are absolute URLs. If the source document contains a relative URL, it will be resolved first.

Post Type Discovery

XRay runs the Post Type Discovery algorithm and also includes a post-type property.

The following post types are returned, which are slightly expanded from what is currently documented by the Post Type Discovery spec.

Other Properties

Other properties are returned in the response at the same level as the data property.

Feeds

XRay can return information for several kinds of feeds. The URL (or body) passed to XRay will be checked for the following formats:

If the page being parsed represents a feed, then the response will look like the following:

Each object in the items array will contain a parsed version of the item, in the same format that XRay normally returns. When parsing Microformats feeds, the authorship discovery will be run for each item to build out the author info.

Atom, RSS and JSONFeed will all be normalized to XRay's vocabulary, and only recognized properties will be returned.

Rels API

There is also an API method to parse and return all rel values on the page, including HTTP Link headers and HTML rel values.

See above for the response format.

Feed Discovery API

See above for the response format.

Token API

When verifying Private Webmentions, you will need to exchange a code for an access token at the token endpoint specified by the source URL.

XRay provides an API that will do this in one step. You can provide the source URL and code you got from the webmention, and XRay will discover the token endpoint, and then return you an access token.

The response will be the response from the token endpoint, which will include an access_token property, and possibly an expires_in property.

If there was a problem fetching the access token, you will get one of the errors below in addition to the HTTP related errors returned by the parse API:

Installation

From Source

From Zip Archive

Web Server Configuration

Configure your web server to point to the public folder.

Make sure all requests are routed to index.php. XRay ships with .htaccess files for Apache. For nginx, you'll need a rule like the following in your server config block.


All versions of xray with dependencies

PHP Build Version
Package Version
Requires mf2/mf2 Version ^0.4||^0.5
ezyang/htmlpurifier Version ^4.10
indieweb/link-rel-parser Version ^0.1.0
dg/twitter-php Version ^3.0.0
p3k/timezone Version ^0.1.0
p3k/http Version ^0.1.0
cebe/markdown Version ^1.1.0
p3k/picofeed Version ^0.1.0
masterminds/html5 Version ^2.3
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 p3k/xray contains the following files

Loading the files please wait ....