Download the PHP package taproot/archive without Composer
On this page you can find all versions of the php package taproot/archive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download taproot/archive
More information about taproot/archive
Files in taproot/archive
Package archive
Short Description Your personal opinionated indieweb- and microformats-oriented HTML archiver.
License MIT
Informations about the package archive
taproot/archive
Your personal opinionated indieweb- and microformats-oriented HTML archiver.
Usage
Install with Composer: ./composer.phar require taproot/archive:~0.1
Creating an archive
Pass a basepath to the constructor — that’s the root of the archive.
Archive a URL
Methods for archiving a URL return an array of [Guzzle Response Object, Error|null]. Typical usage looks like this:
Calling archive will always fetch the latest version of a page from the network and return what it fetched. Along the way, it might also archive it depending on the following conditions:
- is the page served as HTML or XHTML? if not do not archive
- was $force (the second parameter of
archive()set to true? if so, archive - is there already an archived copy of this page?
- if so, compare the two. If they’re cacheably different, archive the new one
So, to ensure another copy of already cached HTML page is made, regardless of them being exactly the same, call $archive->archive($url, true);.
Query strings and hash fragments are ignored when saving archives (hence opinionated), as hash fragments have no effect on the HTML content returned by the server, and using query strings is bad permalink design.
Fetching Archived Pages
There are two ways to fetch pages from the archive: getting a single copy, or getting a list of version IDs (timestamps) which exist for that URL.
Currently if you want to get a particular version of a URL you have to do the dance given above — in the future the get method will be extended to accept a datetime, and returning the closest existing archive to that time, falling back to a fresh copy as usual.
Testing
taproot/archive has a minimal PHPUnit test suite, which at the moment just tests some of the URL-to-filesystem path cases, and does a basic functional test of archiving a page.
Contributions very welcome, whether they’re issues raised or pull requests! If you have a problem and you’re capable of writing a unit test demonstrating it please do, as it makes it so much easier to fix. Otherwise don’t worry, just raise an issue with as much useful information as you can :)
Changelog
v0.1.0
- Initial extraction from Taproot
- Stub of a test suite
- Basic documentation
All versions of archive with dependencies
icap/html-diff Version ~1
guzzlehttp/guzzle Version ~7
psr/http-message Version ~1