Giter Site home page Giter Site logo

bpolaszek / querystring Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 0.0 45 KB

PHP 7.1+ Query String manipulation library. No dependency, immutable, lightweight, PSR-7 compliant.

License: MIT License

PHP 100.00%
php php7 php71 querystring immutable lightweight psr-7 url uri

querystring's Introduction

Latest Stable Version License CI Workflow Coverage Quality Score Total Downloads

QueryString

A lightweight, object-oriented, Query String manipulation library.

Why?

Because I needed an intuitive way to add or remove parameters from a query string, in any project.

Oh, and, I also wanted that ['foos' => ['foo', 'bar']] resolved to foos[]=foo&foos[]=bar instead of foos[0]=foo&foos[1]=bar, unlike many libraries do.

Thanks to object-oriented design, you can define the way query strings are parsed and rendered.

Usage

Simple as that:

require_once __DIR__ . '/vendor/autoload.php';

use function BenTools\QueryString\query_string;

$qs = query_string(
    'foo=bar&baz=bat'
);
$qs = $qs->withParam('foo', 'foofoo')
    ->withoutParam('baz')
    ->withParam('ho', 'hi');

print_r($qs->getParams());
/* Array
(
    [foo] => foofoo
    [ho] => hi
) */

print $qs; // foo=foofoo&ho=hi

Documentation

Instantiation / Parsing

Manipulate parameters

Render as string

Installation

PHP 7.1+ is required.

composer require bentools/querystring:^1.0

Tests

./vendor/bin/phpunit

License

MIT

See also

bentools/uri-factory - A PSR-7 UriInterface factory based on your own dependencies.

bentools/pager - A simple, object oriented Pager.

bentools/where - A framework-agnostic fluent, immutable, SQL query builder.

bentools/picker - Pick a random item from an array, with weight management.

bentools/psr7-request-matcher - A PSR-7 request matcher interface.

bentools/cartesian-product - Generate all possible combinations from a multidimensionnal array.

bentools/string-combinations - A string combinations generator.

bentools/flatten-iterator - An iterator that flattens multiple iterators or arrays.

querystring's People

Contributors

bpolaszek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

querystring's Issues

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.