定制 ivrok/urlmanager 二次开发

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

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

ivrok/urlmanager

最新稳定版本:1.0.2

Composer 安装命令:

composer require ivrok/urlmanager

包简介

URLManager: Efficient PHP URL parsing and management with classes for component handling and URL parsing.

README 文档

README

URLManager is a PHP package designed to facilitate the parsing and management of URLs. It includes two classes, URL and URLHelper, to handle URL components and parsing respectively.

Installation

You can install the package via Composer:

composer require ivrok/urlmanager

Usage

URL Class

The URL class provides methods to set and get URL components such as protocol, domain, and path. It also allows you to add query parameters.

use Ivrok\URLManager\URL;

$url = new URL('example.com');
$url->setHTTPS();
$url->setPath('/index.php');
$url->addQueryParameter('key', 'value');

echo $url; // Outputs: https://example.com/index.php?key=value

URLHelper Class

The URLHelper class includes methods to interact with the URL object:

use Ivrok\URLManager\URLHelper;

$url = URLHelper::parseUrl('https://www.example.com/index.php?key=value');

// Check if a specific query exists
echo URLHelper::hasQuery($url, 'key'); // Outputs: true

// Check if the URL path matches a specific path
echo URLHelper::isPath($url, '/about'); // Outputs: true

// Check if the URL path includes a specific string
echo URLHelper::isPathInclude($url, 'ab'); // Outputs: true

// Check if the domain matches
echo URLHelper::isDomain($url, 'www.example.com'); // Outputs: true

// Check if the domain and top domain matches
echo URLHelper::isDomainOrTopDomain($url, 'example.com'); // Outputs: true

Features

  • Set and get URL components like domain, path, and protocol.
  • Add single or multiple query parameters to a URL.
  • Parse a URL string into a URL object.

License

URLManager is open-source software licensed under the MIT license.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-09