markocupic/url-util
最新稳定版本:1.0.0
Composer 安装命令:
composer require markocupic/url-util
包简介
Parse and manipulate urls in a Symfony Environment
README 文档
README
Url Util
A lightweight Symfony library that provides utility methods for working with URLs. It allows you to add or remove query parameters of a URL. If no URL is provided, the current request URL is used automatically.
✨ Features
- Add query parameters to a URL
- Remove one or more query parameters
- Automatically falls back to the current request URL when no URL is passed
- Cleans up encoded ampersands (
&→&)
📦 Installation
Install via Composer:
composer require markocupic/url-util
🚀 Usage
Inject the UrlUtil service into your controller or service:
class DemoController { public function index(UrlUtil $urlUtil) { // Current request URL: https://example.com/page?foo=bar // Add a single query parameter $newUrl = $urlUtil->addQueryParam('foo_one', 'bar'); // Result: https://example.com/page?foo_one=bar // Add an array parameter $newUrl = $urlUtil->addQueryParams('foo_two', 'biz,buz'], $newUrl); // Result: https://example.com/page?foo_one=bar&foo_two[]=biz&foo_two[]=buz // Remove one or more query parameters $url = 'https://example.com/page?foo=bar&baz=qux'; $newUrl = $urlUtil->removeQueryParam(['foo'], $url); // Result: https://example.com/page?baz=qux } }
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-12-11
