2017 © Pedro Peláez
 

library webpagetest

PHP Library for Interacting with Web Page Test

image

widgetsburritos/webpagetest

PHP Library for Interacting with Web Page Test

  • Monday, January 29, 2018
  • by bighappyface
  • Repository
  • 2 Watchers
  • 6 Stars
  • 1,798 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 27 % Grown

The README.md

webpagetest

Build Status Latest Stable Version License composer.lock, (*1)

A php library for interacting with webpagetest.org., (*2)

Requires PHP 7.1+, (*3)

Usage

Instantiating a new instance

To obtain a key, see Request API Key., (*4)


^ Note: the switching protocol and payment required status checks are not a mistake. As of 10/25/2017, webpagetest.org returns a "101 switching protocols" status for pending tests and a "402 Payment Required" status for cancelled tests., (*5)

Running a URL test

runTest('https://www.google.com')) {
  if ($response->statusCode == StatusCode::OK) {
    // All test info is available in $response->data.
    $test_id = $response->data->testId;
  }
}
?>

The library automatically populates the k, f and url query string parameters. Optionally, you can supply additional parameters by passing in array., (*6)

 'My Test Label',
  'noimages' => 1,
  'mobile' => 1,
];

if ($response = $wpt->runTest('https://www.google.com', $options)) {
  if ($response->statusCode == StatusCode::OK) {
    // All test info is available in $response->data.
    $test_id = $response->data->testId;
  }
}
?>

See the Web Page Test API documentation for more information on supported parameters., (*7)

Getting a test's status

<?php
if ($response = $wpt->getTestStatus($test_id)) {
  // All test info is available in $response->data.
  if ($response->statusCode == StatusCode::OK) {
    // Test is complete.
  }
  else if ($response->statusCode == StatusCode::CONTINUING) {
    // Test is running.
  }
  else if ($response->startCode == StatusCode::SWITCHING_PROTOCOLS) {
    // Test is waiting to start.
  }
  else if ($response->statusCode == StatusCode::PAYMENT_REQUIRED) {
    // Test has been cancelled.
  else {
    // Test failed.
  }
}
?>

Getting a test's results

<?php
if ($response = $wpt->getTestResults($test_id)) {
  // All test result info is available in $response->data.
  if ($response->statusCode == StatusCode::OK) {
    // Test is complete.
  }
  else if (in_array($response->statusCode, [StatusCode::CONTINUING, StatusCode::SWITCHING_PROTOCOLS])) {
    // Test is not yet complete.
  }
  else {
    // Test failed.
  }
}
?>

Getting test locations

<?php
if ($response = $wpt->getLocations()) {
  if ($response->statusCode == StatusCode::OK) {
    // All locations info is available in $response->data.
  }
}
?>

Cancelling a Test

You can cancel a test by simply running:, (*8)

<?php
$wpt->cancelTest($test_id);
?>

The Versions

29/01 2018

dev-master

9999999-dev

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL GPL-3.0-only

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

29/01 2018

1.0.6

1.0.6.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL-3.0-only

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

27/10 2017

1.0.5

1.0.5.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

26/10 2017

1.0.4

1.0.4.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

12/06 2017

1.0.3

1.0.3.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

12/06 2017

1.0.2

1.0.2.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

11/06 2017

1.0.1

1.0.1.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL

The Requires

 

The Development Requires

by Avatar WidgetsBurritos

11/06 2017

1.0.0

1.0.0.0

PHP Library for Interacting with Web Page Test

  Sources   Download

GPL

The Requires

 

The Development Requires

by Avatar WidgetsBurritos