Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Commit f03ca54

Browse files
committed
Updated to 1.1.4 version
1 parent dad369b commit f03ca54

File tree

1,369 files changed

+872
-118725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,369 files changed

+872
-118725
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/tests export-ignore
2-
/src/bootstrap.php export-ignore
3-
/vendor export-ignore
42
.gitattributes export-ignore
53
.gitignore export-ignore
64
_config.yml export-ignore
@@ -10,6 +8,7 @@ phpunit.xml.dist export-ignore
108
CONDUCT.md export-ignore
119
contributors.txt export-ignore
1210
README.md export-ignore
11+
phpcs.ruleset.xml export-ignore
1312
README-ES.md export-ignore
1413
.editorconfig export-ignore
1514
composer.lock export-ignore

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ composer.phar
33
composer.lock
44
composer-test.lock
55
build/artifacts/
6-
artifacts/
6+
vendor/
77
docs/_build
88
docs/*.pyc
99
.git*/

.travis.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,42 @@ sudo: false
44

55
dist: trusty
66

7+
branches:
8+
only:
9+
- master
10+
711
git:
812
depth: 5
913

1014
php:
1115
- 5.6
1216
- 7.0
1317
- 7.1
18+
- 7.2
1419
- hhvm
1520
- nightly
1621

1722
matrix:
1823
fast_finish: true
24+
include:
25+
- php: 7.1
26+
env: PHPCS=PSR2
27+
1928
allow_failures:
2029
- php: nightly
2130

2231
before_script:
23-
- composer self-update
24-
- composer install
32+
- export PATH="./vendor/bin:$PATH"
33+
- travis_retry composer self-update
34+
- travis_retry composer install --no-interaction --prefer-source --dev
2535

2636
script:
27-
- composer test
37+
- phpunit
38+
- |
39+
if [[ "$PHPCS" ]] ; then
40+
phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php')
41+
fi
42+
phpunit --coverage-clover=coverage.xml
43+
44+
after_success:
45+
- bash <(curl -s https://codecov.io/bash)

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# CHANGELOG
22

3+
## 1.1.4 - 2017-10-25
4+
5+
* Implemented `PSR-4 autoloader standard` from all library files.
6+
7+
* Implemented `PSR-2 coding standard` from all library PHP files.
8+
9+
* Implemented `PHPCS` to ensure that PHP code complies with `PSR2` code standards.
10+
11+
* Implemented `Codacy` to automates code reviews and monitors code quality over time.
12+
13+
* Implemented `Codecov` to coverage reports.
14+
15+
* Added `Curl/phpcs.ruleset.xml` file.
16+
17+
* Deleted `Curl/src/bootstrap.php` file.
18+
19+
* Deleted `Curl/tests/bootstrap.php` file.
20+
21+
* Deleted `Curl/vendor` folder.
22+
23+
* Changed `Josantonius\Curl\Test\CurlTest` class to `Josantonius\Curl\CurlTest` class .
24+
325
## 1.1.3 - 2017-09-11
426

527
* Unit tests supported by `PHPUnit` were added.

README-ES.md

Lines changed: 192 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# PHP Curl library
22

3-
[![Latest Stable Version](https://poser.pugx.org/josantonius/curl/v/stable)](https://packagist.org/packages/josantonius/curl) [![Total Downloads](https://poser.pugx.org/josantonius/curl/downloads)](https://packagist.org/packages/josantonius/curl) [![Latest Unstable Version](https://poser.pugx.org/josantonius/curl/v/unstable)](https://packagist.org/packages/josantonius/curl) [![License](https://poser.pugx.org/josantonius/curl/license)](https://packagist.org/packages/josantonius/curl) [![Travis](https://travis-ci.org/Josantonius/PHP-Curl.svg)](https://travis-ci.org/Josantonius/PHP-Curl)
3+
[![Latest Stable Version](https://poser.pugx.org/josantonius/Curl/v/stable)](https://packagist.org/packages/josantonius/Curl) [![Latest Unstable Version](https://poser.pugx.org/josantonius/Curl/v/unstable)](https://packagist.org/packages/josantonius/Curl) [![License](https://poser.pugx.org/josantonius/Curl/license)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/5137ab63729545d78f4a417075a6ce02)](https://www.codacy.com/app/Josantonius/PHP-Curl?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Josantonius/PHP-Curl&amp;utm_campaign=Badge_Grade) [![Total Downloads](https://poser.pugx.org/josantonius/Curl/downloads)](https://packagist.org/packages/josantonius/Curl) [![Travis](https://travis-ci.org/Josantonius/PHP-Curl.svg)](https://travis-ci.org/Josantonius/PHP-Curl) [![PSR2](https://img.shields.io/badge/PSR-2-1abc9c.svg)](http://www.php-fig.org/psr/psr-2/) [![PSR4](https://img.shields.io/badge/PSR-4-9b59b6.svg)](http://www.php-fig.org/psr/psr-4/) [![CodeCov](https://codecov.io/gh/Josantonius/PHP-Curl/branch/master/graph/badge.svg)](https://codecov.io/gh/Josantonius/PHP-Curl)
44

55
[English version](README.md)
66

77
Biblioteca PHP para hacer peticiones HTTP a través de CURL. Fácil integración con API REST.
88

99
---
1010

11-
- [Instalación](#instalación)
1211
- [Requisitos](#requisitos)
13-
- [Cómo empezar y ejemplos](#cómo-empezar-y-ejemplos)
12+
- [Instalación](#instalación)
1413
- [Métodos disponibles](#métodos-disponibles)
14+
- [Cómo empezar](#cómo-empezar)
1515
- [Uso](#uso)
1616
- [Tests](#tests)
1717
- [Manejador de excepciones](#manejador-de-excepciones)
@@ -23,81 +23,242 @@ Biblioteca PHP para hacer peticiones HTTP a través de CURL. Fácil integración
2323

2424
---
2525

26+
### Requisitos
27+
28+
Esta clase es soportada por versiones de `PHP 5.6` o superiores y es compatible con versiones de `HHVM 3.0` o superiores.
29+
2630
### Instalación
2731

28-
La mejor forma de instalar esta extensión es a través de [composer](http://getcomposer.org/download/).
32+
La mejor forma de instalar esta extensión es a través de [Composer](http://getcomposer.org/download/).
2933

30-
Para instalar PHP Curl library, simplemente escribe:
34+
Para instalar `PHP Curl library`, simplemente escribe:
3135

3236
$ composer require Josantonius/Curl
3337

34-
El comando anterior sólo instalará los archivos necesarios, si prefieres descargar todo el código fuente (incluyendo tests, directorio vendor, excepciones no utilizadas, documentos...) puedes utilizar:
38+
El comando anterior sólo instalará los archivos necesarios, si prefieres **descargar todo el código fuente** puedes utilizar:
3539

3640
$ composer require Josantonius/Curl --prefer-source
3741

38-
También puedes clonar el repositorio completo con Git:
42+
También puedes **clonar el repositorio** completo con Git:
3943

4044
$ git clone https://github.com/Josantonius/PHP-Curl.git
4145

42-
### Requisitos
46+
O **instalarlo manualmente**:
47+
48+
[Descargar Curl.php](https://raw.githubusercontent.com/Josantonius/PHP-Curl/master/src/Curl.php):
49+
50+
$ wget https://raw.githubusercontent.com/Josantonius/PHP-Curl/master/src/Curl.php
51+
52+
### Métodos disponibles
4353

44-
Esta biblioteca es soportada por versiones de PHP 5.6 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
54+
Métodos disponibles en esta biblioteca:
55+
56+
`Realizar petición HTTP:`
57+
58+
```php
59+
Curl::request($url, $params, $result);
60+
```
4561

46-
### Cómo empezar y ejemplos
62+
| Atributo | Descripción | Tipo | Requerido | Predeterminado
63+
| --- | --- | --- | --- | --- |
64+
| $url | URL donde realizar la petición. | string | Yes | |
4765

48-
Para utilizar esta biblioteca, simplemente:
66+
| Atributo | Clave | Descripción | Tipo | Requerido | Predeterminado
67+
| --- | --- | --- | --- | --- | --- |
68+
| $params | | Parámetros. | array | No | array() |
69+
| | 'referer' | URL de referencia. | string | No | |
70+
| | 'timeout' | Tiempo de espera. | int | No | |
71+
| | 'agent' | Useragent. | string | No | |
72+
| | 'headers' | Encabezados HTTP. | array | No | |
73+
| | 'data' | Parámetros para enviar. | array | No | |
74+
| | 'type' | Tipo de petición. | string | No | |
75+
76+
| Atributo | Descripción | Tipo | Requerido | Predeterminado
77+
| --- | --- | --- | --- | --- |
78+
| $result | Devuelve el resultado como array u objeto. | string | No | 'array' |
79+
80+
**# Return** (array|object) → respuesta
81+
82+
### Cómo empezar
83+
84+
Para utilizar esta clase con `Composer`:
4985

5086
```php
5187
require __DIR__ . '/vendor/autoload.php';
5288

5389
use Josantonius\Curl\Curl;
5490
```
5591

56-
### Métodos disponibles
57-
58-
Métodos disponibles en esta biblioteca:
92+
Si la instalaste `manualmente`, utiliza:
5993

6094
```php
61-
Curl::request();
95+
require_once __DIR__ . '/Curl.php';
96+
97+
use Josantonius\Curl\Curl;
6298
```
6399

64100
### Uso
65101

66102
Ejemplo de uso para esta biblioteca:
67103

104+
**Enviar petición GET y obtener respuesta como array:**
105+
68106
```php
69-
<?php
70-
require __DIR__ . '/vendor/autoload.php';
107+
Curl::request('https://graph.facebook.com/zuck');
108+
```
71109

72-
use Josantonius\Curl\Curl;
110+
**Enviar petición GET y obtener respuesta como objeto:**
111+
112+
```php
113+
Curl::request('https://graph.facebook.com/zuck', false, 'object');
114+
```
115+
116+
**Enviar petición GET con parámetros y obtener respuesta como array:**
117+
118+
```php
119+
$data = [
120+
'timeout' => 10,
121+
'referer' => 'http://site.com',
122+
];
123+
124+
Curl::request('https://graph.facebook.com/zuck', $data);
125+
```
126+
127+
**Enviar petición GET con parámetros y obtener respuesta como objeto:**
128+
129+
```php
130+
$data = [
131+
'timeout' => 10,
132+
'referer' => 'http://site.com',
133+
];
134+
135+
Curl::request('https://graph.facebook.com/zuck', $data, 'object');
136+
```
137+
138+
**Enviar petición POST y obtener respuesta como array:**
139+
140+
```php
141+
$data = [
142+
'type' => 'post',
143+
'data' => array('user' => '123456', 'password' => 'xxxxx'),
144+
'timeout' => 10,
145+
'referer' => 'http://' . $_SERVER['HTTP_HOST'],
146+
'headers' => [
147+
'Content-Type:application/json',
148+
'Authorization:0kdm3hzmb4h3cf',
149+
],
150+
];
151+
152+
Curl::request('https://graph.facebook.com/zuck', $data);
153+
```
73154

155+
**Enviar petición POST y obtener respuesta como objeto:**
156+
157+
```php
74158
$data = [
159+
'type' => 'post',
160+
'data' => array('user' => '123456', 'password' => 'xxxxx'),
161+
'timeout' => 10,
162+
'referer' => 'http://' . $_SERVER['HTTP_HOST'],
163+
'headers' => [
164+
'Content-Type:application/json',
165+
'Authorization:0kdm3hzmb4h3cf',
166+
],
167+
];
168+
169+
Curl::request('https://graph.facebook.com/zuck', $data, 'object');
170+
```
75171

76-
'type' => 'post',
77-
'data' => array('user' => '123456', 'password' => 'xxxxx'),
78-
'timeout' => 10,
79-
'referer' => 'http://'.$_SERVER['HTTP_HOST'],
80-
'headers' => [
172+
**Enviar petición PUT y obtener respuesta como array:**
81173

82-
'Content-Type:application/json',
83-
'Authorization:0kdm3hzmb4h3cf'
84-
]
174+
```php
175+
$data = [
176+
'type' => 'put',
177+
'data' => array('email' => 'new@email.com'),
178+
'timeout' => 30,
179+
'referer' => 'http://' . $_SERVER['HTTP_HOST'],
180+
'headers' => [
181+
'Content-Type:application/json',
182+
'Authorization:0kdm3hzmb4h3cf',
183+
],
85184
];
185+
186+
Curl::request('https://graph.facebook.com/zuck', $data);
187+
```
86188

87-
$response = Curl::request('https://graph.facebook.com/zuck', $data);
189+
**Enviar petición PUT y obtener respuesta como objeto:**
88190

89-
echo "<pre>"; var_dump($response); echo "</pre>";
191+
```php
192+
$data = [
193+
'type' => 'put',
194+
'data' => array('email' => 'new@email.com'),
195+
'timeout' => 30,
196+
'referer' => 'http://' . $_SERVER['HTTP_HOST'],
197+
'headers' => [
198+
'Content-Type:application/json',
199+
'Authorization:0kdm3hzmb4h3cf',
200+
],
201+
];
202+
203+
Curl::request('https://graph.facebook.com/zuck', $data, 'object');
204+
```
205+
206+
**Enviar petición DELETE y obtener respuesta como array:**
207+
208+
```php
209+
$data = [
210+
211+
'type' => 'delete',
212+
'data' => ['userId' => 10],
213+
'timeout' => 30,
214+
'referer' => 'http://' . $_SERVER['HTTP_HOST'],
215+
'headers' => [
216+
'Content-Type:application/json',
217+
'Authorization:0kdm3hzmb4h3cf',
218+
],
219+
];
220+
221+
Curl::request('https://graph.facebook.com/zuck', $data);
222+
```
223+
224+
**Enviar petición DELETE y obtener respuesta como objeto:**
225+
226+
```php
227+
$data = [
228+
'type' => 'delete',
229+
'data' => ['userId' => 10],
230+
'timeout' => 30,
231+
'referer' => 'http://' . $_SERVER['HTTP_HOST'],
232+
'headers' => [
233+
'Content-Type:application/json',
234+
'Authorization:0kdm3hzmb4h3cf',
235+
],
236+
];
237+
238+
Curl::request('https://graph.facebook.com/zuck', $data, 'object');
90239
```
91240

92241
### Tests
93242

94-
Para ejecutar las [pruebas](tests/Curl/Test) simplemente:
243+
Para ejecutar las [pruebas](tests) necesitarás [Composer](http://getcomposer.org/download/) y seguir los siguientes pasos:
95244

96245
$ git clone https://github.com/Josantonius/PHP-Curl.git
97246

98247
$ cd PHP-Curl
99248

100-
$ phpunit
249+
$ composer install
250+
251+
Ejecutar pruebas unitarias con [PHPUnit](https://phpunit.de/):
252+
253+
$ composer phpunit
254+
255+
Ejecutar pruebas de estándares de código [PSR2](http://www.php-fig.org/psr/psr-2/) con [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):
256+
257+
$ composer phpcs
258+
259+
Ejecutar todas las pruebas anteriores:
260+
261+
$ composer tests
101262

102263
### Manejador de excepciones
103264

@@ -106,7 +267,7 @@ Esta biblioteca utiliza [control de excepciones](src/Exception) que puedes perso
106267
### ☑ Tareas pendientes
107268

108269
- [x] Completar tests
109-
- [ ] Mejorar la documentación
270+
- [x] Mejorar la documentación
110271

111272
### Contribuir
112273

0 commit comments

Comments
 (0)