iansltx/pnwphp-2017-schedule-client

A nicely-wrapped scraper for the PNWPHP 2017 conference schedule

dev-master / 1.0.x-dev 2017-09-06 03:43 UTC

This package is auto-updated.

Last update: 2024-11-06 18:58:24 UTC


README

Scrapes the PNWPHP 2017 schedule, providing a list of conference events.

This file is syntactically valid PHP, so you can run it to see how the examples work. And yes, that's why there are close-tags everywhere.

To start, composer require iansltx/pnwphp-2017-schedule-client. Then:

<?php

require __DIR__ . '/vendor/autoload.php';

$client = \iansltx\PNWPHP2017ScheduleClient\Client::create(); // set up a client with default params
print("Getting schedule...\n");
$schedule = $client->getSchedule(); // make the call to the PNWPHP website and scrape the schedule

?>

A schedule is an event collection with a few convenience methods, containing Event objects, which implement __toString() and jsonSerialize(). Both return a string suitable for display, so if you want more data in your JSON blob you'll want to pull data out of each event manually.

<?php

date_default_timezone_set('America/Los_Angeles');
/** @var \iansltx\PNWPHP2017ScheduleClient\Schedule $schedule */
print("The next event is " . $schedule->filterOutPast(new \DateTimeImmutable('2017-09-10'))->first() . ".\n");

?>