简化PHP中的URL处理

1.0.2 2023-08-23 21:07 UTC

This package is auto-updated.

Last update: 2024-09-24 00:02:55 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version Latest Monthly Downloads License

关于PHP-URL

这样工作

像专业人士一样做 🆗

安装

  • composer require transprime-research/php-url

快速使用

这样使用...

$url = new Url(
    fullDomain: 'https://:8080',
    path: '/api/hello',
    query: ['name' => 'John', 'public' => 'yes'],
);

// Or

$url = Url::make(
    scheme: 'http://',
    domain: 'localhost',
    port: '8080',
    path: '/api/hello',
    query: ['name' => 'John', 'public' => 'yes'],
);


(string) $url; // https://:8080/api/hello?name=John&public=yes
$url->toString(); // https://:8080/api/hello?name=John&public=yes

其他用法

$url = Url::make()
    ->setScheme('http://')
    ->setDomain('localhost')
    ->setPort('8080')
    ->setPath('/api/hello')
    ->addToQuery('name', 'John')
    ->addToQuery('public', 'yes');

(string) $url; // https://:8080/api/hello?name=John&public=yes

即将推出

API实现待定

附加信息

在此查看此系列中的其他软件包

类似软件包

  • luzzardi/php-url
  • martinmdev/php-url
  • simlux/php-url
  • thesmart/php-url

许可协议

MIT (见LICENCE文件)