Skip to content

Commit

Permalink
First Purl commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Jan 11, 2013
0 parents commit 7842b25
Show file tree
Hide file tree
Showing 17 changed files with 8,053 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: php

php:
- 5.3
- 5.4

before_script:
- wget http://getcomposer.org/composer.phar
- php composer.phar install
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2013 Purl Project

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
94 changes: 94 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Purl
====

Purl is a simple OO URL manipulation library for PHP 5.3+

[![Build Status](https://secure.travis-ci.org/jwage/Purl.png?branch=master)](http://travis-ci.org/jwage/Purl)

Using Purl
----------

### To create a `Url` instance is easy:

```php
<?php

$url = new \Purl\Url('http://jwage.com');

You can also create `Url` instances through the static `parse` method:

```php
<?php

$url = Purl::parse('http://jwage.com');

The benefit is that you can chain additional calls after creating the `Url`:

```php
<?php

$url = \Purl\Url::parse('http://jwage.com')
->set('schema', 'https')
->set('port', '443')
->set('user', 'jwage')
->set('pass', 'password')
->set('path', 'about/me')
->set('query', 'param1=value1&param2=value2')
->set('fragment', 'about/me?param1=value1&param2=value2');

echo $url->getUrl(); // https://jwage:passwordjwage.com:443/about/me?param1=value1&param2=value2#about/me?param1=value1&param2=value2

// $url->path becomes instanceof Purl\Path
// $url->query becomes insstanceof Purl\Query
// $url->fragment becomes instanceof Purl\Fragment

### Path Manipulation

```php
<?php
$url = new \Purl\Url('http://jwage.com');

// add path segments one at a time
$url->path->add('about')->add('me');

// set the path data from a string
$url->path = 'about/me/another_segment'; // $url->path becomes instanceof Purl\Path

// get the path segments
print_r($url->path->getData()); // array('about', 'me', 'another_segment')

### Query Manipulation

```php
<?php
$url = new \Purl\Url('http://jwage.com');
$url->query->set('param1', 'value1');
$url->query->set('param2', 'value2');

echo $url->query; // param1=value1&param2=value2
echo $url; // http://jwage.com?param1=value1&param2=value2

// set the query data from an array
$url->query->setData(array(
'param1' => 'value1',
'param2' => 'value2'
));

// set the query data from a string
$url->query = 'param1=value1&param2=value2'; // $url->query becomes instanceof Purl\Query
print_r($url->query->getData()); //array('param1' => 'value1', 'param2' => 'value2')

### Fragment Manipulation

```php
<?php
$url = new \Purl\Url('http://jwage.com');
$url->fragment 'about/me?param1=value1&param2=value2'; // $url->fragment becomes instanceof Purl\Fragment

A Fragment is made of a path and a query and comes after the hashmark (#).

```php
<?php
echo $url->fragment->path; // about/me
echo $url->fragment->query; // param1=value1&param2=value2
echo $url; // http://jwage.com#about/me?param1=value1&param2=value2
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"autoload": {
"psr-0": {"Purl": "src/"}
},
"require": {
"phpunit/phpunit": "3.7.*"
}
}
Binary file added composer.phar
Binary file not shown.
Loading

0 comments on commit 7842b25

Please sign in to comment.