UrlFactory help you to manage URL.

Overview

UrlFactory

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

You might also like...
590+ usernames in this dictionary! A list of reserved usernames to prevent url collision with resource paths.

590+ usernames in this dictionary! A list of reserved usernames to prevent url collision with resource paths. This repository hosts the list in multiple formats like JSON, CSV, SQL and plain text. You can use its just download its by wget.

Unicode-url-for-Textpattern - Plugin for using unicode urls instead of transliterations to ASCII characters

Unicode-url-for-Textpattern Summary textpattern plugin wcz_utf8_url – uses UTF-8 permlinks instead of transliterated ones for SEO Features automatical

Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Magento 2 extension. Solution for set Url of Category without Parent path.

Magento 2 extension. Solution for set Url of Category without Parent path.

Url's amigables en PHP

Phurl - Url's amigables en PHP Motor de url's amigables minimalista y sencillo de usar, crea tus vistas en Html plano. No es compatible con variables

Magento 2 module which can find potential url related problems in your catalog data
Magento 2 module which can find potential url related problems in your catalog data

Url data integrity checker module for Magento 2 Purpose The purpose of this module is to give store owners of a Magento 2 shop insight into what url-r

A Magento 2 module that allows for creating discrete PDP (Product Detail Pages) page layouts for customers landing on the site from a PPC (Pay Per Click) link/ad by allowing routing to the same pages using a `/ppc/` prefix in the URL path.
A Magento 2 module that allows for creating discrete PDP (Product Detail Pages) page layouts for customers landing on the site from a PPC (Pay Per Click) link/ad by allowing routing to the same pages using a `/ppc/` prefix in the URL path.

A Magento 2 module that allows for creating discrete PDP (Product Detail Pages) page layouts for customers landing on the site from a PPC (Pay Per Click) link/ad by allowing routing to the same pages using a `/ppc/` prefix in the URL path.

Generate static map url for maptiler.com
Generate static map url for maptiler.com

PHP static maps url generator The package is used for static maps (images) URL generate. For now, it works only with maptiler.com. I welcome your comm

Releases(v1.0.0-a.1)
Owner
Nahid Bin Azhar
Code makes me happy than anything. So I contribute to open source and enjoy happiness.
Nahid Bin Azhar
A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

null 3 Jul 29, 2022
This tool can help you to see the real IP behind CloudFlare protected websites.

CrimeFlare Bypass Hostname Alat untuk melihat IP asli dibalik website yang telah dilindungi CloudFlare. Introduction Alat ini berfungsi untuk melakuka

zidan rahmandani 126 Oct 20, 2021
A composer package designed to help you create a JSON:API in Phalcon

phalcon-json-api-package A composer package designed to help you create a JSON:API in Phalcon What happens when a PHP developer wants to create an API

Jim 35 Nov 27, 2020
A library of powerful code snippets to help you get the job done with Gravity Forms and Gravity Perks.

Gravity Wiz Snippet Library Gravity Wiz is creating the most comprehensive library of snippets for Gravity Forms ever. We'll be consistently moving ou

Gravity Wiz 132 Sep 15, 2022
Composer registry manager that help to easily switch to the composer repository you want

CRM - Composer Registry Manager Composer Registry Manager can help you easily and quickly switch between different composer repositories. 简体中文 Install

Tao 491 Sep 20, 2022
PHP functions that help you validate structure of complex nested PHP arrays.

PHP functions that help you validate structure of complex nested PHP arrays.

cd rubin 7 May 22, 2022
A set of PHP classes to let you manage your Dynamic Widget UI programmatically.

Dynamic Widget for Flutter A set of PHP classes to let you manage your Dynamic Widget UI programmatically. Why? Why not? Developing my application I f

Agostino Fiscale 3 Mar 22, 2022
Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.

laravelpodcast | A Laravel podcast manager package - v0.0.8 Introduction Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3

Jeremy Kenedy 21 Oct 3, 2021
Venture allows you to create and manage complex, async workflows in your Laravel apps.

Venture is a package to help you build and manage complex workflows of interdependent jobs using Laravel's queueing system. Installation Note: Venture

Kai Sassnowski 654 Sep 22, 2022
Magento 2 Blog is an extension that allows you to manage your store and blog

Magento 2 Blog Extension by Magefan Magento 2 Blog is an extension that allows you to manage your store and blog from one place without having to rely

Magefan 236 Aug 23, 2022