PHPackages                             kajna/purli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. kajna/purli

ActiveLibrary[HTTP &amp; Networking](/categories/http)

kajna/purli
===========

 Lightweight library with Object-Oriented interface for sending HTTP requests

1.0.0(8y ago)35.2k—0%11MITPHPPHP &gt;=5.4.0CI failing

Since Sep 25Pushed 2y ago2 watchersCompare

[ Source](https://github.com/ACTIV8-Developers/Purli)[ Packagist](https://packagist.org/packages/kajna/purli)[ RSS](/packages/kajna-purli/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

Purli
=====

[](#purli)

[![DUB](https://camo.githubusercontent.com/17e9757cbb55c60de819f19cd32613d4fc879fe79b5e6d9e8fbbb534328adee2/68747470733a2f2f696d672e736869656c64732e696f2f6475622f6c2f766962652d642e737667)](http://opensource.org/licenses/MIT)[![Version](https://camo.githubusercontent.com/97f85f046265623c4b26076add9bcc55f9608152c20e78f07076369977c77d05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d677265656e2e737667)](https://github.com/Kajna/Purli/releases)

Purli (PHP Url Interface) is the lightweight library with the object-oriented interface for sending HTTP requests.

Installing
==========

[](#installing)

This package is available via [Composer](https://getcomposer.org/):

```
{
  "require": {
    "kajna/purli": "dev-master"
  }
}
```

Usage examples
==============

[](#usage-examples)

#### Fetching data using GET method and CURL handler

[](#fetching-data-using-get-method-and-curl-handler)

Minimal example, Purli by default uses CURL handler if available otherwise fallback to the socket.

```
try {
    $purli = (new \Purli\Purli())
        ->get('http://www.example.com')
        ->close();

    $response = $purli->response();

    echo $response->asText();
} catch(\Exception $e) {
    echo $e->getMessage();
}
```

#### Fetching data using GET method and socket handler

[](#fetching-data-using-get-method-and-socket-handler)

If explicitly set Purli will use PHP sockets to make requests regardless if CURL is installed or not

```
try {
    $purli = (new \Purli\Purli(\Purli\Purli::SOCKET))
            ->get('http://example.com')
            ->close();

    $response = $purli->response();

    echo $response->asText();
} catch(\Exception $e) {
	echo $e->getMessage();
}
```

#### Fetching data using POST method

[](#fetching-data-using-post-method)

```
try {
    $data = array('foo' => 'bar');

    $purli = (new \Purli\Purli())
        ->setParams($data)
        ->post('http://www.example.com')
        ->close();

    $response = $purli->response();

    print_r($response->asText());
} catch(\Exception $e) {
    echo $e->getMessage();
}
```

#### Sending and receiving XML data using POST method

[](#sending-and-receiving-xml-data-using-post-method)

```
try {
    $data = 'bar';

    $purli = (new \Purli\Purli())
        ->setUserAgent('curl 7.16.1 (i386-portbld-freebsd6.2) libcurl/7.16.1 OpenSSL/0.9.7m zlib/1.2.3')
        ->setHeader('Content-Type', 'text/xml')
        ->setParams($data)
        ->post('http://www.example.com')
        ->close();

    $response = $purli->response();

    print_r($response->asArray());
} catch(\Exception $e) {
    echo $e->getMessage();
}
```

#### Sending and receiving JSON data using PUT method

[](#sending-and-receiving-json-data-using-put-method)

```
try {
    $data = array('foo' => 'bar');
    $json = json_encode($data);

    $purli = (new \Purli\Purli(\Purli\Purli::SOCKET))
            ->setConnectionTimeout(3)
            ->setHeader('Content-Type', 'application/json')
            ->setParams($json)
            ->put('http://www.example.com')
            ->close();

    $response = $purli->response();

    print_r($response->asObject());
} catch(\Exception $e) {
	echo $e->getMessage();
}
```

#### Using proxy server to make request

[](#using-proxy-server-to-make-request)

```
try {
    $purli = (new \Purli\Purli());

    $purli
        ->setProxy(PROXY_ADDRESS, PROXY_PORT)
        ->get('http://www.example.com')
        ->close();

    $response = $purli->response();

    echo $response->asText();
} catch(\Exception $e) {
    echo $e->getMessage();
}
```

#### Setting custom CURL option

[](#setting-custom-curl-option)

If CURL extension is installed by default Purli will use it, you can always get CURL handler object and set custom option if more flexibility is needed

```
try {
    $purli = (new \Purli\Purli());

    if ($purli->getHandlerType() === \Purli\Purli::CURL) {
        curl_setopt($purli->getHandler(), CURLOPT_TIMEOUT, 10);
    }

    $purli
        ->get('http://www.example.com')
        ->close();

    $response = $purli->response();

    echo $response->asText();
} catch(\Exception $e) {
    echo $e->getMessage();
}
```

Running tests
=============

[](#running-tests)

Purli uses [PHPUnit](https://phpunit.de/) for testing, navigate to project root directory and run command:

```
cd tests
phpunit

```

Author
======

[](#author)

Milos Kajnaco

Contributors
============

[](#contributors)

Nemanja Nikolic

Licence
=======

[](#licence)

Purli is released under the [MIT](http://opensource.org/licenses/MIT) public license.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 84.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~408 days

Total

2

Last Release

3109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05b21474c04a1957849d3f9c496a37c868340646b1e5c7c5226e72689415a5db?d=identicon)[Kajna](/maintainers/Kajna)

---

Top Contributors

[![Kajna](https://avatars.githubusercontent.com/u/4723904?v=4)](https://github.com/Kajna "Kajna (11 commits)")[![massvisiondotnet](https://avatars.githubusercontent.com/u/10510840?v=4)](https://github.com/massvisiondotnet "massvisiondotnet (2 commits)")

---

Tags

apicurlhttphttpclientphppurlisocketwebserviceshttphttpsjsonrestxmlcurlSocket

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kajna-purli/health.svg)

```
[![Health](https://phpackages.com/badges/kajna-purli/health.svg)](https://phpackages.com/packages/kajna-purli)
```

###  Alternatives

[tcdent/php-restclient

A generic REST API client for PHP

3542.9M29](/packages/tcdent-php-restclient)[crell/api-problem

PHP wrapper for the api-problem IETF specification

2482.0M20](/packages/crell-api-problem)[apimatic/unirest-php

Unirest PHP

224.7M116](/packages/apimatic-unirest-php)[vinelab/http

An http library developed for the laravel framework. aliases itself as HttpClient

59300.2k11](/packages/vinelab-http)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69114.3k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
