jumpifbelow/php-uri

定义URI的类

4.0.1 2019-06-13 11:39 UTC

This package is auto-updated.

Last update: 2024-09-23 22:09:42 UTC


README

一个简单的类,用于定义什么是URI,并且可以轻松转换为字符串。

如何安装?

使用Composer常规方式

composer require jumpifbelow/php-uri

它看起来像什么?

<?php
use Uri\Uri;

$uri = new Uri();

$uri
    ->setScheme('https')
    ->setHost('jsonplaceholder.typicode.com')
    ->setPath('/posts/1')
;

// will contain https://jsonplaceholder.typicode.com/posts/1
$string = $uri->__toString();

// can change the port of the protocol
$uri->setPort(8000);

// can handle authentication
$uri
    ->setUsername('user')
    ->setPassword('password')
;

// will contain https://user:password@jsonplaceholder.typicode.com:8000/posts/1
$string = $uri->__toString();