Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://editorconfig.org/

root = true

[*]
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
charset = utf-8
tab_width = 4
indent_size = 4
indent_style = space
24 changes: 24 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ci

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run test suite
run: composer run-script test
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
Thumbs.db
/.idea
/.vscode

/vendor
/coverage
/build
composer.phar
composer.lock
.phpunit.result.cache
sample.php
phpDocumentor.phar
101 changes: 97 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,116 @@

## Usage

*Placeholder; Rather than starting to delve into the API docs, it'd be great to see what the client looks like in action in this lang plus a rough description what it does. The dev should be able to quickly determine whether the example fits the desired style and problem.*
Send requests to a Nimiq node using a `NimiqCommunity\RpcClient\NimiqClient` object.

```php
$config = [
'scheme' => 'http',
'host' => '127.0.0.1',
'port' => 8648,
'user' => 'luna',
'password' => 'moon',
'timeout' => false,
];

$client = new \NimiqCommunity\RpcClient\NimiqClient($config);
```

Once we have the client, we can start communicating with the Nimiq node.
If no `$config` object is given in constructor it will use same defaults as the Nimiq node defaults.

```php
$client = new \NimiqCommunity\RpcClient\NimiqClient();

// make rpc call to get the block number
$blockNumber = $client->getBlockNumber();

echo $blockNumber; // displays the block number, for example 748883
```

## API

*Placeholder; All the implemented methods with parameters, types, default values, return types*
The complete [API documentation](docs) is available in the `/docs` folder.

Check out the [Nimiq RPC specs](https://github.com/nimiq/core-js/wiki/JSON-RPC-API) for behind the scene RPC calls.

## Installation

*Placeholder; how to add this client to a project. Each language comes with a package manager. To be useful for developers, add a package description file that works with the most commonly used package manager for this language. For example have a `package.json` file for JavaScript or `pom.xml` for Java.*
The recommended way to install Nimiq PHP Client is with Composer. Composer is a dependency management tool for PHP that
allows you to declare the dependencies your project needs and installs them into your project.

```sh
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

You can add Nimiq PHP Client as a dependency using the composer.phar CLI:

```sh
php composer.phar require nimiq-community/php-client
```

Alternatively, you can specify it as a dependency in your project's existing composer.json file:

```json
{
"require": {
"nimiq-community/php-client": "^1.0"
}
}
```

After installing, you need to require Composer's autoloader:

```php
require 'vendor/autoload.php';
```

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at [getcomposer.org](https://getcomposer.org).

## Contributions

This implementation was originally contributed by [*Placeholder; Your name with link to GitHub*](https://github.com/nimiq/).
This implementation was originally contributed by [mariofriz](https://github.com/mariofriz/).

Please send your contributions as pull requests.
Refer to the [issue tracker](https://github.com/nimiq-community/php-client/issues) for ideas.

### Develop

After cloning the repository, install the dependencies:

```sh
php composer.phar install
```

All done, happy coding!

### Testing

Tests are stored in the `/tests` folder and can be run using phpunit:

```sh
php composer.phar run-script test
```

To run the tests and generate HTML coverage report:

```sh
php composer.phar run-script coverage
```

This will generate the report in `/coverage` folder. [Xdebug](https://xdebug.org/docs/install) is required to generate the coverage report.

### Documentation

The documentation in the `/docs` folder can generated from the source code:

```sh
php composer.phar run-script docs
```

It will generate a `README.md` in Github Markdown format.

## License

[Apache 2.0](LICENSE.md)
34 changes: 34 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "nimiq-community/php-client",
"description": "Nimiq RPC Client for PHP",
"homepage": "https://github.com/nimiq-community/php-client",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Mario",
"role": "Developer"
}
],
"scripts": {
"test": "vendor/bin/phpunit",
"coverage": "vendor/bin/phpunit --coverage-html coverage",
"docs": "vendor/bin/phpdoc"
},
"require": {
"php": ">=7.1",
"guzzlehttp/guzzle": "^6.5"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"cvuorinen/phpdoc-markdown-public": "^0.2"
},
"autoload": {
"psr-4": {
"NimiqCommunity\\RpcClient\\": "src"
},
"files": [
"src/functions.php"
]
}
}
Loading