Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mlevent/purl
https://github.com/mlevent/purl
manipulate php uri url-builder
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mlevent/purl
- Owner: mlevent
- License: mit
- Created: 2020-12-01T11:32:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T16:49:24.000Z (about 2 years ago)
- Last Synced: 2024-12-10T01:31:48.130Z (30 days ago)
- Topics: manipulate, php, uri, url-builder
- Language: PHP
- Homepage: https://mlevent.github.io/purl
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
🧾 Purl
PHP için URL oluşturma ve manipülasyon aracı.
## Kurulum
🛠️ Paketi composer ile projenize dahil edin;
```bash
composer require mlevent/purl
```## URL OluĹźturma
```php
use Mlevent\Purl;$url = new Purl;
$args = [
'category' => 'bestSellers',
'colors' => [
'red',
'blue',
'black',
],
'sort' => 'desc',
'page' => 2,
];/**
* @output
* https://github.com/shop/?category=bestSellers&colors=red,blue,black&sort=desc&page=2
*/
echo $url->path('shop')
->args($args)
->build();
/**
* @output
* https://google.com/shop/?category=bestSellers&colors=red,blue,black&sort=desc&page=2
*/
echo $url->baseUrl('https://google.com')
->path('shop')
->args($args)
->build();/**
* @output
* shop/?category=bestSellers&colors=red,blue,black&sort=desc&page=2
*/
echo $url->baseUrl(false)
->path('shop')
->args($args)
->build();
```## ManipĂĽlasyon
```php
/**
* @current
* https://github.com/products/?colors=blue&sizes=S,M,L&sort=price&page=2
*
* @output
* https://github.com/products/?colors=blue,red,black&sort=price
*/
echo $url->args(['colors' => ['red', 'black']])
->deny('sizes', 'page')
->push();
/**
* @current
* https://github.com/products/?colors=blue&sizes=S,M,L&sort=price&page=2
*
* @output
* https://github.com/products/?colors=blue&sizes=S,M,L
*/
echo $url->allow('colors', 'sizes')
->push();
```## Metodlar
```php
/**
* @param nullable|string $arg
* @return array
*/
$url->getArgs($arg);/**
* @return array
*/
$url->getAllowedArgs();/**
* @return array
*/
$url->getDeniedArgs();/**
* @return string
* @example /category/electronics/telephone
*/
$url->getPath();/**
* @return string
* @example category
*/
$url->getPath(0);/**
* @param string $arg
* @return boolean
*/
$url->hasArg($args);/**
* @param string $value
* @return boolean
*/
$url->hasValue($value);/**
* @return string
*/
$url->getCurrentUrl();
```