GithubHelp home page GithubHelp logo

dheia / uri Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thephpleague/uri

0.0 0.0 0.0 2.51 MB

URI manipulation Library

Home Page: https://uri.thephpleague.com

License: MIT License

PHP 100.00%

uri's Introduction

URI

Build Software License Latest Version Total Downloads

The Uri package provides simple and intuitive classes to manage URIs in PHP. You will be able to

  • parse, build and resolve URIs
  • create URIs from different sources (string, PHP environment, base URI, URI template, ...);
  • handle internalisation;
  • infer properties and features from URIs;
<?php

use League\Uri\UriTemplate;

$template = 'https://api.twitter.com:443/{version}/search/{term:1}/{term}/{?q*,limit}#title';
$defaultVariables = ['version' => '1.1'];
$params = [
    'term' => 'john',
    'q' => ['a', 'b'],
    'limit' => '10',
];

$uriTemplate = new UriTemplate($template, $defaultVariables);
$uri = $uriTemplate->expand($params);
// $uri is a League\Uri\Uri object

echo $uri->getScheme();    //displays "https"
echo $uri->getAuthority(); //displays "api.twitter.com:443"
echo $uri->getPath();      //displays "/1.1/search/j/john/"
echo $uri->getQuery();     //displays "q=a&q=b&limit=10"
echo $uri->getFragment();  //displays "title"
echo $uri;
//displays "https://api.twitter.com:443/1.1/search/j/john/?q=a&q=b&limit=10#title"
echo json_encode($uri);
//displays "https:\/\/api.twitter.com:443\/1.1\/search\/j\/john\/?q=a&q=b&limit=10#title"

Highlights

System Requirements

  • You require PHP >= 7.2 but the latest stable version of PHP is recommended
  • You will need the ext-intl to handle i18n URI.
  • Since version 6.2.0 you will need the ext-fileinfo to handle Data URI creation from a filepath.

Dependencies

In order to handle IDN host you are required to also install the intl extension otherwise an exception will be thrown when attempting to validate such host.

In order to create Data URI from a filepath, since version 6.2, you are required to also install the fileinfo extension otherwise an exception will be thrown.

Installation

$ composer require league/uri

Documentation

Full documentation can be found at uri.thephpleague.com.

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING and CONDUCT for details.

Testing

The library has a :

  • a PHPUnit test suite
  • a coding style compliance test suite using PHP CS Fixer.
  • a code analysis compliance test suite using PHPStan.

To run the tests, run the following command from the project folder.

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Attribution

The UriTemplate class is adapted from the Guzzle 6 project.

License

The MIT License (MIT). Please see License File for more information.

uri's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.