Skip to content

Commit

Permalink
Started the migration from XMLNuke
Browse files Browse the repository at this point in the history
  • Loading branch information
byjg committed Jul 22, 2015
0 parents commit dcb31a5
Show file tree
Hide file tree
Showing 78 changed files with 10,834 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nbproject/private
*~
composer.lock
vendor
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: php
php:
- "5.6"
- "5.5"
- "5.4"

install:
- composer install

script:
- cd tests
- phpunit -v --bootstrap bootstrap.php src/WebRequestTest.php

20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2015 Joao Gilberto Magalhaes

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Web Request
[![Build Status](https://travis-ci.org/byjg/webrequest.svg?branch=master)](https://travis-ci.org/byjg/webrequest)
[![Build Status](https://drone.io/github.com/byjg/webrequest/status.png)](https://drone.io/github.com/byjg/webrequest/latest)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/7cfbd581-fdb6-405d-be0a-afee0f70d30c/mini.png)](https://insight.sensiolabs.com/projects/7cfbd581-fdb6-405d-be0a-afee0f70d30c)

## Description

A lightweight and highly customized CURL wrapper for making RESt calls and a wrapper for call dynamically SOAP requests.
Just one class and no dependencies.

## Examples

### Basic Usage

```php
$webRequest = new WebRequest('http://www.example.com/page');
$result = $webRequest->get();
//$result = $webRequest->post();
//$result = $webRequest->delete();
//$result = $webRequest->put();
```

### Passing arguments

```php
$webRequest = new WebRequest('http://www.example.com/page');
$result = $webRequest->get(['param'=>'value']);
//$result = $webRequest->post(['param'=>'value']);
//$result = $webRequest->delete(['param'=>'value']);
//$result = $webRequest->put(['param'=>'value']);
```

### Passing a string payload (JSON)

```php
$webRequest = new WebRequest('http://www.example.com/page');
$result = $webRequest->postPayload('{teste: "value"}', 'application/json');
//$result = $webRequest->putPayload('{teste: "value"}', 'application/json');
//$result = $webRequest->deletePayload('{teste: "value"}', 'application/json');
```

### Setting Custom CURL PARAMETER

```php
$webRequest = new WebRequest('http://www.example.com/page');
$webRequest->setCurlOption(CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
$result = $webRequest->get();
```

### Calling Soap Classes

```php
$webRequest = new WebRequest('http://www.example.com/soap');
$resutl = $webRequest->soapCall('soapMethod', ['arg1' => 'value']);
```


## Install

Just type: `composer install "byjg/webrequest=1.0.0"`

## Running Tests

### Starting the server

```php
cd tests
php -S localhost:8080 -t server &
```

**Note:** It is more assertive create a webserver with the server folder instead to use the PHP built-in webserver.

### Running the integration tests

```php
cd tests
phpunit --bootstrap bootstrap.php src/WebRequestTest.php
```

### Stopping the server

```php
killall -9 php
```
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "byjg/anydataset",
"description": "A data abstration layer in PHP with several repository types and standartize interface to operate it",
"authors": [
{
"name": "João Gilberto Magalhães",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"ByJG\\AnyDataset\\": "src/",
"Tests\\": "tests/"
}
},
"require": {
"php": ">=5.4.0",
"byjg/xmlutil": "~1.0",
"byjg/sparqllib": "dev-master",
"neitanod/forceutf8": "dev-master"
},
"license": "MIT"
}
16 changes: 16 additions & 0 deletions example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

require "vendor/autoload.php";

$webRequest = new \ByJG\Util\WebRequest('http://www.byjg.com.br/ws/cep');

echo $webRequest->get([
'httpmethod' => 'obterVersao'
]) . "\n";

echo $webRequest->post([
'httpmethod' => 'obterLogradouro',
'cep' => '30130000'
]) . "\n";

echo $webRequest->soapCall('obterLogradouro', ['cep' => '30130000']) . "\n";
21 changes: 21 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_create_2e_tests=false
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_enabled=true
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_path=tests/bootstrap.php
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_enabled=false
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_enabled=false
auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_enabled=false
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.test_2e_groups_2e_ask=false
auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_all=false
file.reference.anydataset-tests=tests
include.path=${php.global.include.path}
php.version=PHP_54
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
test.src.dir=${file.reference.anydataset-tests}
testing.providers=PhpUnit
web.root=.
9 changes: 9 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>anydataset</name>
</data>
</configuration>
</project>
Loading

0 comments on commit dcb31a5

Please sign in to comment.