定制 markocupic/url-util 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

markocupic/url-util

最新稳定版本:1.0.0

Composer 安装命令:

composer require markocupic/url-util

包简介

Parse and manipulate urls in a Symfony Environment

README 文档

README

Alt text

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-12-11