A little library used to get the size of a URL.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
README.md
composer.json
composer.phar

README.md

UrlTools

A little library of tools used to get information about URLs using a command line interface. ZF2 service interface coming soon!

Installation

Git

$ git clone git@github.com:philsown/UrlTools.git UrlTools
$ cd UrlTools
$ php composer.phar install -o

Composer

Add something like this to your composer.json file.

{
    "repositories": [
        {
            "url": "https://github.com/philsown/UrlTools.git",
            "type": "git"
        }
    ],
    "require": {
        "philsown/UrlTools": "dev-master"
    }
}

Configuration

Copy the config dist files in src/data to config.ini or config.json respectively, and edit them to add the URLs you would like the sizes of.

Config Files

$ cd src/data
$ cp config.ini.dist config.ini
$ cp config.json.dist config.json
$ # edit the new config files here

Output Path

Make sure your output path is writable. We recommend the src/data folder for starters.

$ cd src
$ chmod u+w data

Tip: your output path could be anywhere, really.

Usage

Iteration 1

This will get a URL from an INI config file, find the size of that URL (if possible), and write the result to an INI file like so:

url = "{url}"
size = {size}

The INI config file should be formatted like so:

url = "{url}"

Usage

$ cd src
$ php urlsize.php url:size --type ini --config-file data/config.ini --output-path data/

Iteration 2

This will get a set of URLs from a JSON config file, find the size of each URL (if possible), and write the result to a JSON file like so:

{
	"urls": [
		"{url}": "{size}",
		"{url}": "{size}",
		// etc...
	]
}

The JSON config file should be formatted like so:

{
	"urls": [
		"{url}",
		"{url}",
		// etc...
	]
}

Usage

$ cd src
$ php urlsize.php url:size --type json --config-file data/config.json --output-path data/

Iteration 3

As in Iteration 2, this will get a set of URLs from a JSON config file, find the size of each URL (if possible), and write the result to a JSON file. If a given URL responds with a Content-Type of text/html, then the size of all URLs found in anchor, image, link, and script tag hrefs and srcs are added to the first URL's size result.

//TODO Not yet implemented.

TODO

  • Iteration 3.
  • Make the HttpService configuration something that can be injected, perhaps from autoload in a Zend App
  • Make this more Zend App-ish.
  • Clean up config & injection in general
  • Rename the Size\Output classes to Writer, since that's how they're used.
  • Replace the fopen in the Writers to use Zend Writer Stream classes.
  • Put OutputAbstract (WriterAbstract) start & finish methods into the Interface.
  • The HTTP status header is not checked on the response. That is, 404's, etc. are not handled.
  • Probably more.

I Made This

Author: Phillip Harrington.