Skip to content

Commit

Permalink
Misc improvements:
Browse files Browse the repository at this point in the history
- add travis-ci
- add launch of rserve instance using docker to readme
- removed duplicate readme file
- add to readme how to use with composer
- add phpunit and parallel-lint to composer require-dev
- add test script tag to composer file
- add composer.lock file
- change default port in sample file to 6311 for convenience in travis-ci test
  • Loading branch information
shadiakiki1986 committed Sep 15, 2016
1 parent bada195 commit e2a7428
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 98 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.project
.buildpath
.settings
vendor
20 changes: 20 additions & 0 deletions .travis.yml
@@ -0,0 +1,20 @@
sudo: required

services:
- docker

language: php

php:
- 7

before_install:
- composer install
- cp tests/config.php.sample tests/config.php
- docker run -d -p 6311:6311 wnagele/rserve

script:
- composer test

after_success:
- docker ps|grep rserve|awk '{print "docker stop " $1}'|bash
85 changes: 0 additions & 85 deletions README

This file was deleted.

41 changes: 30 additions & 11 deletions README.md
Expand Up @@ -3,6 +3,8 @@ Rserve-php

php5 client for Rserve http://www.rforge.net/Rserve/ (a TCP/IP server for R statistical software)

[![Build Status](https://travis-ci.org/shadiakiki1986/rserve-php.svg?branch=2.0-improvements)](https://travis-ci.org/shadiakiki1986/rserve-php)

Changes from 1.0 version
---
- All classes are declared under Sentiweb\Rserve namespace allowin PSR-4 autoloading
Expand All @@ -14,13 +16,27 @@ Tests

You can run tests using phpunit


Credential-free tests
* launch your credential-free Rserve instance
. Can be done with

docker run -d -p 6311:6311 wnagele/rserve

* Create a file config.php in the "tests" directory (copy config.php.sample)
* define the constant RSERVE_HOST with the address of your Rserve server (custom port not supported yet)
* run tests
. phpunit --bootstrap=src/autoload.php tests/ParserNativeTest.php
* define the constant `RSERVE_HOST` with the address of your Rserve server
. port used is the default 6311
. custom port implemented but not supported in tests yet
* if installed with composer: `composer test`
* otherwise, run with `phpunit`
. phpunit tests/ParserNativeTest.php
. phpunit tests\SessionTest.php
. phpunit tests\REXPTest.php
* define the constants RSERVE_PORT, RSERVE_USER, RSERVE_PASS to config.php (along with RSERVE_HOST)


Login tests:
* launch your credential-protected Rserve instance
* define the constants `RSERVE_PORT, RSERVE_USER, RSERVE_PASS` in config.php (along with `RSERVE_HOST`)
* run test
. phpunit tests\LoginTest.php

Expand All @@ -32,15 +48,18 @@ Using without composer :
include src/autoload.php in your project

Using with composer:
TBD
* run `composer require cturbelin/rserve-php:2.0.x-dev`
* add `require __DIR__.'/../vendor/autoload.php';` to your project

Some usage example are provided in example/ directory
Some usage example are provided in [example](example) directory


Using Login Authorization
-------------------------
Usage is the same as the vanilla usage, except for the constructor
$cnx = new Connection('myserverhost', serverport, array('username'=>username,'password'=>password))
```php
$cnx = new \Sentiweb\Rserve\Connection('myserverhost', serverport, array('username'=>username,'password'=>password))
```

Parsers
-----
Expand All @@ -51,7 +70,7 @@ Results provided by R could be handled using several parsers
Translate R structure into php simple arrays. It is useful to get simple values from R

- Wrapped array
Using NativeArray with parameters array("wrapper"=>true) in contructor return object
Using NativeArray with parameters `array("wrapper"=>true)` in contructor return object
with attributes of R objects.
The result object is used as an array and also provides methods to access attributes()

Expand All @@ -74,6 +93,6 @@ Several functions allow to use connection in async mode

Contacts
--------
Clément Turbelin, clement.turbelin@gmail.com
http://www.sentiweb.fr
Université Pierre et Marie Curie - Paris 6, France
* Clément Turbelin, clement.turbelin@gmail.com
* http://www.sentiweb.fr
* Université Pierre et Marie Curie - Paris 6, France
12 changes: 11 additions & 1 deletion composer.json
Expand Up @@ -14,10 +14,20 @@
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "*",
"jakub-onderka/php-parallel-lint": "^0.9"
},
"autoload": {
"files": ["src/lib/helpers.php"],
"psr-4": {
"Sentiweb\\Rserve\\": "src/"
}
}
},
"scripts": {
"test": [
"parallel-lint . --exclude vendor --exclude doc",
"phpunit --verbose"
]
}
}
20 changes: 20 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/config.php.sample
Expand Up @@ -2,7 +2,7 @@
define('RSERVE_HOST','localhost');

// Used in LoginTest.php
define('RSERVE_PORT', 1234);
define('RSERVE_PORT', 6311);
define('RSERVE_USER','user');
define('RSERVE_PASS','pass');

0 comments on commit e2a7428

Please sign in to comment.