forked from jwage/purl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7842b25
Showing
17 changed files
with
8,053 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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+ | ||
|
||
[](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¶m2=value2') | ||
->set('fragment', 'about/me?param1=value1¶m2=value2'); | ||
|
||
echo $url->getUrl(); // https://jwage:passwordjwage.com:443/about/me?param1=value1¶m2=value2#about/me?param1=value1¶m2=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¶m2=value2 | ||
echo $url; // http://jwage.com?param1=value1¶m2=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¶m2=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¶m2=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¶m2=value2 | ||
echo $url; // http://jwage.com#about/me?param1=value1¶m2=value2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Oops, something went wrong.