https://github.com/mlevent/purl
https://github.com/mlevent/purl
manipulate php uri url-builder
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mlevent/purl
- Owner: mlevent
- License: mit
- Created: 2020-12-01T11:32:48.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T16:49:24.000Z (over 3 years ago)
- Last Synced: 2025-04-08T19:01:57.436Z (about 1 year 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();
```