承接 nahid/url-factory 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nahid/url-factory

最新稳定版本:v1.0.0-a.1

Composer 安装命令:

composer require nahid/url-factory

包简介

UrlFactory is a PHP package for working with URLs

README 文档

README

UrlFactory is a PHP package for working with URLs. Its offer you to best developer experience to manage and manipulate URLs. UrlFactory offers simple, yet powerful ways of working with query string, paths and domain.

Requirements

  • php >= 8.0

  • ext-json

  • ext-intl

Installation

UrlFactory is available on Packagist. You can directly install it in any package by running this command bellow

composer require nahid/url-factory

Configuration

There are no extra configuration needed to run this package, but by passing config you can take more control over this package.

Default Config

// use Nahid\UrlFactory\Enum;
[
    Enum::CONFIG_KEY => 'secret-key',
    Enum::CONFIG_SIGNER => MD5UrlSigner::class,
    Enum::CONFIG_PSR_CACHE_INTERFACE => null,
    Enum::CONFIG_PSR_CLIENT_INTERFACE => null,
    Enum::CONFIG_PSR_REQUEST_FACTORY_INTERFACE => null,
]

you can modify it as you want and pass into UrlFactory when initialize

Syntax

new Url([string $url, [array $config]]);

Both arguments of the construct are optional

Initialization

use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;


$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);

We use http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20 for our next examples

Example

URL Extract and Fetch

use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;


$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);

echo $url->getScheme() . "\n";
echo $url->getQuery() . "\n";
var_dump($url->getQueryParam()) . "\n";
echo $url->getPath() . "\n";
echo $url->domain()->getSubdomain() . "\n";
echo $url->domain()->getSuffix() . "\n";
echo $url->domain()->getTld() . "\n";
Output
http
q=bangladesh&page=1&limit=20
['q' => 'bangladesh', 'page '=> 1, 'limit' => 20]
private/search
app.staging
com.bd
com

URL Modification

use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;


$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);


$url->useSchemeHttps()
    ->usePath('query')
    ->useQueryParams(['search'=> 'dhaka'])
    ->useFragment('top')
    ->domain(function(\Nahid\UrlFactory\Domain $domain) {
        $domain->useBaseName('bing')
            ->useSuffix('co.in')
            ->useSubdomain('app');
    });

echo $url->get()

Output

https://app.bing.co.in/query?search=dhaka#top

Signed URL

use Nahid\UrlFactory\Url;
use Nahid\UrlFactory\Enum;


$url = new Url('http://app.staging.google.com.bd/private/search?q=bangladesh&page=1&limit=20', [
    Enum::CONFIG_KEY => 'random-secret-key',
]);


$url->useSchemeHttps()
    ->usePath('query')
    ->useQueryParams(['search'=> 'dhaka'])
    ->useFragment('top')
    ->domain(function(\Nahid\UrlFactory\Domain $domain) {
        $domain->useBaseName('bing')
            ->useSuffix('co.in')
            ->useSubdomain('app');
    });

echo $url->sign(7)->get(); // Generate signed URL with 7 days validity
 

Output

https://app.bing.co.in/query?search=dhaka&expires=1661613403&signature=5fd3f94c145731a085f6964cb3c4d03d#top

API List

There are lots of API are available with this package. We'll update it ASAP

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固