ngsoft / url
esperecyan/url fork that uses a polyfill for intl and is compatible with psr-7 specifications.
Requires
- php: >=5.4.7
- ext-ctype: *
- ext-filter: *
- ext-iconv: *
- ext-json: *
- ext-pcre: *
- esperecyan/webidl: ^2.0.0
- psr/http-message: ^1.0
- symfony/polyfill-intl-idn: ^1.11
- symfony/polyfill-mbstring: ^1.3.0
Requires (Dev)
- ext-dom: *
- ext-spl: *
- apigen/apigen: 4.2.0-RC1 || ^4.2.0
- phpunit/phpunit: ^5.7.17
README
English / 日本語
URL Standard
Makes the algorithms and APIs defined by URL Standard available on PHP.
Description
URL Standard is the Web standard specification that replaces the previous standards RFC 3986 and RFC 3987.
The specification defines URL interface and URLSearchPrams interface as API. This library allows you to use esperecyan\url\URL class as URL interface and esperecyan\url\URLSearchParams class as URLSearchPrams interface. The documents on MDN may be easy to understand by way of explanation of the interfaces https://developer.mozilla.org/docs/Web/API/URL https://developer.mozilla.org/docs/Web/API/URLSearchParams .
This library allows you to use the algorithms defined by URL Standard. For details, see The correspondence table of the algorithms.
Example
<?php require_once 'vendor/autoload.php'; use esperecyan\url\URL; $url = new URL('http://url.test/foobar?name=value'); var_dump($url->protocol, $url->pathname, $url->searchParams->get('name'));
The above example will output:
string(5) "http:"
string(7) "/foobar"
string(5) "value"
Requirement
- PHP 5.4 or later (PHP 5.4 and 5.5 are deprecated)
- SPL Types PECL library is not supported
- Intl extension module
Install
composer require esperecyan/url
For help with installation of Composer, see Composer documentation.
Contribution
- Fork it ( https://github.com/esperecyan/url )
- Create your feature branch
git checkout -b my-new-feature
- Commit your changes
git commit -am 'Add some feature'
- Push to the branch
git push origin my-new-feature
- Create new Pull Request
Or
Create new Issue
If you find any mistakes of English in the README or Doc comments or any flaws in tests, please report by such as above means. I also welcome translations of README too.
Acknowledgement
I use the code from コードポイントから UTF-8 の文字を生成する - Qiita and UTF-8 の文字からコードポイントを求める - Qiita in implementing URLencoding class.
I use URL Standard (Japanese translation) as reference in creating this library.
HADAA helped me translate README to English.
Semantic Versioning
This library uses Semantic Versioning. The classes, methods, constants, and properties in the documentation of the library are the public API.
Licence
This library is licensed under the Mozilla Public License Version 2.0 (MPL-2.0).
The correspondence table of the algorithms
5. application/x-www-form-urlencoded | |
---|---|
application/x-www-form-urlencoded parser | esperecyan\url\lib\URLencoding::parseURLencoded() |
application/x-www-form-urlencoded byte serializer | esperecyan\url\lib\URLencoding::serializeURLencodedByte() |
application/x-www-form-urlencoded serializer | esperecyan\url\lib\URLencoding::serializeURLencoded() |
application/x-www-form-urlencoded string parser | esperecyan\url\lib\URLencoding::parseURLencodedString() |
name-value or name-value-type tuples | An array of two-element or three-element arrays with the first element the name, the second the value, and the third the type. The value is an array with the value for name key as the name |