Skip to content

Commit

Permalink
Change root namespace and vendor prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Brecht-Precht committed Jan 18, 2021
1 parent d110a71 commit de3a634
Show file tree
Hide file tree
Showing 33 changed files with 166 additions and 166 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH
Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PHP Basic HTTP Client

[![Build Status](https://travis-ci.org/markenwerk/php-basic-http-client.svg?branch=master)](https://travis-ci.org/markenwerk/php-basic-http-client)
[![Build Status](https://travis-ci.org/chroma-x/php-basic-http-client.svg?branch=master)](https://travis-ci.org/chroma-x/php-basic-http-client)
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/0bc596c2-5849-4e0f-a46f-a7b94d28f97c.svg)](https://insight.sensiolabs.com/projects/0bc596c2-5849-4e0f-a46f-a7b94d28f97c)
[![Code Climate](https://codeclimate.com/github/markenwerk/php-basic-http-client/badges/gpa.svg)](https://codeclimate.com/github/markenwerk/php-basic-http-client)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/03db69a367dd4bbbbbd03e4612dfdbe5)](https://www.codacy.com/app/Bonscho/php-basic-http-client?utm_source=github.com&utm_medium=referral&utm_content=markenwerk/php-basic-http-client&utm_campaign=Badge_Grade)
[![Latest Stable Version](https://poser.pugx.org/markenwerk/basic-http-client/v/stable)](https://packagist.org/packages/markenwerk/basic-http-client)
[![Total Downloads](https://poser.pugx.org/markenwerk/basic-http-client/downloads)](https://packagist.org/packages/markenwerk/basic-http-client)
[![License](https://poser.pugx.org/markenwerk/basic-http-client/license)](https://packagist.org/packages/markenwerk/basic-http-client)
[![Code Climate](https://codeclimate.com/github/chroma-x/php-basic-http-client/badges/gpa.svg)](https://codeclimate.com/github/chroma-x/php-basic-http-client)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/03db69a367dd4bbbbbd03e4612dfdbe5)](https://www.codacy.com/app/Bonscho/php-basic-http-client?utm_source=github.com&utm_medium=referral&utm_content=chroma-x/php-basic-http-client&utm_campaign=Badge_Grade)
[![Latest Stable Version](https://poser.pugx.org/chroma-x/basic-http-client/v/stable)](https://packagist.org/packages/chroma-x/basic-http-client)
[![Total Downloads](https://poser.pugx.org/chroma-x/basic-http-client/downloads)](https://packagist.org/packages/chroma-x/basic-http-client)
[![License](https://poser.pugx.org/chroma-x/basic-http-client/license)](https://packagist.org/packages/chroma-x/basic-http-client)

A basic yet extensible HTTP client library providing different authentication methods written in PHP.

Expand All @@ -26,7 +26,7 @@ Find out more at the [„PSR-7 is imminent, and here's my issues with it“](htt
```{json}
{
"require": {
"markenwerk/basic-http-client": "~3.0"
"chroma-x/basic-http-client": "~3.0"
}
}
```
Expand All @@ -44,9 +44,9 @@ require_once('path/to/vendor/autoload.php');
#### Preparing the HTTP client

```{php}
use Markenwerk\BasicHttpClient;
use Markenwerk\BasicHttpClient\Request\Authentication;
use Markenwerk\BasicHttpClient\Request\Message;
use ChromaX\BasicHttpClient;
use ChromaX\BasicHttpClient\Request\Authentication;
use ChromaX\BasicHttpClient\Request\Message;
// Instantiating a basic HTTP client with the endpoints URL
// If the endpoint uses the `HTTPS` schema a `HttpsTransport` instance will be used automatically.
Expand Down Expand Up @@ -134,7 +134,7 @@ The following example shows the usage with a more detailed configuration.
#### Configuring a HTTP Transport instance

```{php}
use Markenwerk\BasicHttpClient\Request\Transport\HttpTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpTransport;
// Configuring a Transport instance
$transport = new HttpTransport();
Expand All @@ -150,7 +150,7 @@ $transport
#### Configuring a HTTPS Transport instance

```{php}
use Markenwerk\BasicHttpClient\Request\Transport\HttpsTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpsTransport;
// Configuring a Transport instance
$transport = new HttpsTransport();
Expand All @@ -167,10 +167,10 @@ $transport
#### Configuring a Message instance with Body

```{php}
use Markenwerk\BasicHttpClient\Request\Message\Body\Body;
use Markenwerk\BasicHttpClient\Request\Message\Cookie\Cookie;
use Markenwerk\BasicHttpClient\Request\Message\Header\Header;
use Markenwerk\BasicHttpClient\Request\Message\Message;
use ChromaX\BasicHttpClient\Request\Message\Body\Body;
use ChromaX\BasicHttpClient\Request\Message\Cookie\Cookie;
use ChromaX\BasicHttpClient\Request\Message\Header\Header;
use ChromaX\BasicHttpClient\Request\Message\Message;
// Configuring a message Body instance
$messageBody = new Body();
Expand Down Expand Up @@ -218,12 +218,12 @@ $message->addAdditionalHeader(new Header('Custom-Header', array('AnotherCustomHe

#### Configuring an endpoints URL, build the Request instance and perform the HTTP request

For more information about the usage of the URL object please take a look at the [PHP URL Util](/~https://github.com/markenwerk/php-url-util) project.
For more information about the usage of the URL object please take a look at the [PHP URL Util](/~https://github.com/chroma-x/php-url-util) project.

```{php}
use Markenwerk\BasicHttpClient\Request\Authentication\BasicAuthentication;
use Markenwerk\BasicHttpClient\Request\Request;
use Markenwerk\UrlUtil\Url;
use ChromaX\BasicHttpClient\Request\Authentication\BasicAuthentication;
use ChromaX\BasicHttpClient\Request\Request;
use ChromaX\UrlUtil\Url;
// Setting up the endpoints URL
$url = new Url('https://john:secret@yourapihere-com-98yq3775xff0.runscope.net:443/path/to/resource?arg1=123#fragment');
Expand Down Expand Up @@ -273,8 +273,8 @@ You can add one or more Authentication instances to every Request instance. At t
Required credentials are a *username* and a *password* that get provided to the class constructor as arguments.

```{php}
use Markenwerk\BasicHttpClient\Request\Authentication\BasicAuthentication;
use Markenwerk\BasicHttpClient\Request\Request;
use ChromaX\BasicHttpClient\Request\Authentication\BasicAuthentication;
use ChromaX\BasicHttpClient\Request\Request;
// Configuring the authentication
$basicAuthentication = new BasicAuthentication('username', 'password');
Expand All @@ -289,8 +289,8 @@ $request->addAuthentication($basicAuthentication);
Required credentials are a *Certificate Authority Certificate*, a *Client Certificate* and the password that is used to decrypt the Client Certificate that get provided to the class constructor as arguments.

```{php}
use Markenwerk\BasicHttpClient\Request\Authentication\ClientCertificateAuthentication;
use Markenwerk\BasicHttpClient\Request\Request;
use ChromaX\BasicHttpClient\Request\Authentication\ClientCertificateAuthentication;
use ChromaX\BasicHttpClient\Request\Request;
// Configuring the authentication
$clientCertificateAuthentication = new ClientCertificateAuthentication(
Expand All @@ -313,7 +313,7 @@ $request->addAuthentication($clientCertificateAuthentication);
If using the `BasicHttpClient` the response object is returned by the termination methods listed above. If directly using the Request instance, you can get the Response object via a getter.

```{php}
// Getting the response Markenwerk\BasicHttpClient\Response\Response object
// Getting the response ChromaX\BasicHttpClient\Response\Response object
$response = $request->getResponse();
// Reading the HTTP status code as integer; will return `200`
Expand All @@ -322,7 +322,7 @@ echo print_r($response->getStatusCode(), true) . PHP_EOL;
// Reading the HTTP status text as string; will return `HTTP/1.1 200 OK`
echo print_r($response->getStatusText(), true) . PHP_EOL;
// Reading the HTTP response headers as array of Markenwerk\BasicHttpClient\Response\Header\Header objects
// Reading the HTTP response headers as array of ChromaX\BasicHttpClient\Response\Header\Header objects
echo print_r($response->getHeaders(), true) . PHP_EOL;
// Reading the HTTP response body as string
Expand All @@ -345,7 +345,7 @@ echo print_r($request->getEffectiveStatus(), true) . PHP_EOL;
// Getting the effective raw request headers as string
echo print_r($request->getEffectiveRawHeader(), true) . PHP_EOL;
// Getting the effective request headers as array of `Markenwerk\BasicHttpClient\Request\Message\Header\Header` objects
// Getting the effective request headers as array of `ChromaX\BasicHttpClient\Request\Message\Header\Header` objects
echo print_r($request->getEffectiveHeaders(), true) . PHP_EOL.PHP_EOL;
```

Expand All @@ -354,7 +354,7 @@ echo print_r($request->getEffectiveHeaders(), true) . PHP_EOL.PHP_EOL;
## Getting some transactional statistics

```{php}
// Getting the statistics Markenwerk\BasicHttpClient\Response\Statistics\Statistics object
// Getting the statistics ChromaX\BasicHttpClient\Response\Statistics\Statistics object
$statistics = $request->getResponse()->getStatistics();
// Reading the redirection URL if the server responds with an redirect HTTP header and
Expand Down Expand Up @@ -390,32 +390,32 @@ echo print_r($statistics->getTotalTime(), true).PHP_EOL;
Every part of the client is based upon proper interfaces. Most class instances can get injected into the client itself.
If you want to extend the client just write some classes implementing the according interface and you´re done with that.

Take a look at the [PHP JSON HTTP Client](/~https://github.com/markenwerk/php-json-http-client) which is an extension of the PHP Basic HTTP Client.
Take a look at the [PHP JSON HTTP Client](/~https://github.com/chroma-x/php-json-http-client) which is an extension of the PHP Basic HTTP Client.

---

## Exception handling

PHP Basic HTTP Client provides different exceptions – also provided by the PHP Common Exceptions project – for proper handling.
You can find more information about [PHP Common Exceptions at Github](/~https://github.com/markenwerk/php-common-exceptions).
You can find more information about [PHP Common Exceptions at Github](/~https://github.com/chroma-x/php-common-exceptions).

### Exceptions to be expected

In general you should expect that any setter method could thrown an `\InvalidArgumentException`. The following exceptions could get thrown while using PHP Basic HTTP Client.

- `Markenwerk\CommonException\IoException\FileNotFoundException` on configuring a `ClientCertificateAuthentication`instance
- `Markenwerk\CommonException\IoException\FileReadableException` on configuring a `ClientCertificateAuthentication`instance
- `Markenwerk\BasicHttpClient\Exception\HttpRequestAuthenticationException` on performing a request
- `Markenwerk\BasicHttpClient\Exception\HttpRequestException` on performing a request
- `Markenwerk\CommonException\NetworkException\ConnectionTimeoutException` on performing a request
- `Markenwerk\CommonException\NetworkException\CurlException` on performing a request
- `ChromaX\CommonException\IoException\FileNotFoundException` on configuring a `ClientCertificateAuthentication`instance
- `ChromaX\CommonException\IoException\FileReadableException` on configuring a `ClientCertificateAuthentication`instance
- `ChromaX\BasicHttpClient\Exception\HttpRequestAuthenticationException` on performing a request
- `ChromaX\BasicHttpClient\Exception\HttpRequestException` on performing a request
- `ChromaX\CommonException\NetworkException\ConnectionTimeoutException` on performing a request
- `ChromaX\CommonException\NetworkException\CurlException` on performing a request

---

## Contribution

Contributing to our projects is always very appreciated.
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](/~https://github.com/markenwerk/php-basic-http-client/blob/master/CONTRIBUTING.md) document.**
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](/~https://github.com/chroma-x/php-basic-http-client/blob/master/CONTRIBUTING.md) document.**

## License

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "markenwerk/basic-http-client",
"name": "chroma-x/basic-http-client",
"type": "library",
"description": "A basic yet extensible HTTP client library providing different authentication methods written in PHP.",
"keywords": [
Expand All @@ -10,25 +10,25 @@
"Basic Auth",
"Client Certificate Auth"
],
"homepage": "http://markenwerk.net/",
"homepage": "http://chroma-x.de/",
"license": "MIT",
"authors": [
{
"name": "Martin Brecht-Precht",
"email": "mb@markenwerk.net",
"homepage": "http://markenwerk.net"
"email": "mb@chroma-x.de",
"homepage": "http://chroma-x.de"
}
],
"autoload": {
"psr-4": {
"Markenwerk\\BasicHttpClient\\": "src/"
"ChromaX\\BasicHttpClient\\": "src/"
}
},
"require": {
"php": "^7.1",
"ext-curl": "*",
"ext-mbstring": "*",
"markenwerk/url-util": "~2.0",
"markenwerk/common-exceptions": "~3.0"
"chroma-x/url-util": "~2.0",
"chroma-x/common-exceptions": "~3.0"
}
}
24 changes: 12 additions & 12 deletions src/BasicHttpClient.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

namespace Markenwerk\BasicHttpClient;
namespace ChromaX\BasicHttpClient;

use Markenwerk\BasicHttpClient\Request\RequestInterface;
use Markenwerk\BasicHttpClient\Request\Message\Body\Body;
use Markenwerk\BasicHttpClient\Request\Message\Message;
use Markenwerk\BasicHttpClient\Request\Request;
use Markenwerk\BasicHttpClient\Request\Transport\HttpsTransport;
use Markenwerk\BasicHttpClient\Request\Transport\HttpTransport;
use Markenwerk\BasicHttpClient\Response\ResponseInterface;
use Markenwerk\CommonException\NetworkException\Base\NetworkException;
use Markenwerk\CommonException\NetworkException\ConnectionTimeoutException;
use Markenwerk\UrlUtil\Url;
use ChromaX\BasicHttpClient\Request\RequestInterface;
use ChromaX\BasicHttpClient\Request\Message\Body\Body;
use ChromaX\BasicHttpClient\Request\Message\Message;
use ChromaX\BasicHttpClient\Request\Request;
use ChromaX\BasicHttpClient\Request\Transport\HttpsTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpTransport;
use ChromaX\BasicHttpClient\Response\ResponseInterface;
use ChromaX\CommonException\NetworkException\Base\NetworkException;
use ChromaX\CommonException\NetworkException\ConnectionTimeoutException;
use ChromaX\UrlUtil\Url;

/**
* Class BasicHttpClient
*
* @package Markenwerk\BasicHttpClient
* @package ChromaX\BasicHttpClient
*/
class BasicHttpClient implements HttpClientInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/HttpRequestAuthenticationException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\BasicHttpClient\Exception;
namespace ChromaX\BasicHttpClient\Exception;

/**
* Class HttpRequestAuthenticationException
*
* @package Markenwerk\BasicHttpClient\Exception
* @package ChromaX\BasicHttpClient\Exception
*/
class HttpRequestAuthenticationException extends \Exception
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/HttpRequestException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\BasicHttpClient\Exception;
namespace ChromaX\BasicHttpClient\Exception;

/**
* Class HttpRequestException
*
* @package Markenwerk\BasicHttpClient\Exception
* @package ChromaX\BasicHttpClient\Exception
*/
class HttpRequestException extends \Exception
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/HttpRequestMessageException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\BasicHttpClient\Exception;
namespace ChromaX\BasicHttpClient\Exception;

/**
* Class HttpRequestMessageException
*
* @package Markenwerk\BasicHttpClient\Exception
* @package ChromaX\BasicHttpClient\Exception
*/
class HttpRequestMessageException extends \Exception
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/HttpResponseException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Markenwerk\BasicHttpClient\Exception;
namespace ChromaX\BasicHttpClient\Exception;

/**
* Class HttpResponseException
*
* @package Markenwerk\BasicHttpClient\Exception
* @package ChromaX\BasicHttpClient\Exception
*/
class HttpResponseException extends \Exception
{
Expand Down
8 changes: 4 additions & 4 deletions src/HttpClientInterface.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Markenwerk\BasicHttpClient;
namespace ChromaX\BasicHttpClient;

use Markenwerk\BasicHttpClient\Request\RequestInterface;
use Markenwerk\BasicHttpClient\Response\ResponseInterface;
use ChromaX\BasicHttpClient\Request\RequestInterface;
use ChromaX\BasicHttpClient\Response\ResponseInterface;

/**
* Interface HttpClientInterface
*
* @package Markenwerk\BasicHttpClient
* @package ChromaX\BasicHttpClient
*/
interface HttpClientInterface
{
Expand Down
30 changes: 15 additions & 15 deletions src/Request/AbstractRequest.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php

namespace Markenwerk\BasicHttpClient\Request;

use Markenwerk\BasicHttpClient\Exception\HttpRequestException;
use Markenwerk\BasicHttpClient\Request\Authentication\AuthenticationInterface;
use Markenwerk\BasicHttpClient\Request\Message\MessageInterface;
use Markenwerk\BasicHttpClient\Request\Message\Header\Header;
use Markenwerk\BasicHttpClient\Request\Transport\TransportInterface;
use Markenwerk\BasicHttpClient\Request\Transport\HttpsTransport;
use Markenwerk\BasicHttpClient\Request\Transport\HttpTransport;
use Markenwerk\BasicHttpClient\Response\ResponseInterface;
use Markenwerk\CommonException\NetworkException\Base\NetworkException;
use Markenwerk\CommonException\NetworkException\ConnectionTimeoutException;
use Markenwerk\CommonException\NetworkException\CurlException;
use Markenwerk\UrlUtil\UrlInterface;
namespace ChromaX\BasicHttpClient\Request;

use ChromaX\BasicHttpClient\Exception\HttpRequestException;
use ChromaX\BasicHttpClient\Request\Authentication\AuthenticationInterface;
use ChromaX\BasicHttpClient\Request\Message\MessageInterface;
use ChromaX\BasicHttpClient\Request\Message\Header\Header;
use ChromaX\BasicHttpClient\Request\Transport\TransportInterface;
use ChromaX\BasicHttpClient\Request\Transport\HttpsTransport;
use ChromaX\BasicHttpClient\Request\Transport\HttpTransport;
use ChromaX\BasicHttpClient\Response\ResponseInterface;
use ChromaX\CommonException\NetworkException\Base\NetworkException;
use ChromaX\CommonException\NetworkException\ConnectionTimeoutException;
use ChromaX\CommonException\NetworkException\CurlException;
use ChromaX\UrlUtil\UrlInterface;

/**
* Class Request
*
* @package Markenwerk\BasicHttpClient\Request
* @package ChromaX\BasicHttpClient\Request
*/
abstract class AbstractRequest implements RequestInterface
{
Expand Down
Loading

0 comments on commit de3a634

Please sign in to comment.