This package provides a simple service provider for the Factom API for use with the Laravel Framework.
Factom API documentation: https://docs.factom.com/api
Note: This package is under development and should not be used for production environments.
You can install this package via composer using:
composer require adrianmejias/factom-api
You must also install this service provider in conifg/app.php
.
'providers' => [
...
AdrianMejias\FactomApi\FactomApiServiceProvider::class,
...
The package will automatically register itself. If not, then add the alias in config/app.php
.
'aliases' => [
...
'FactomApi' => AdrianMejias\FactomApi\Facades\FactomApi::class,
'FactomWalletApi' => AdrianMejias\FactomApi\Facades\FactomWalletApi::class,
'FactomDebugApi' => AdrianMejias\FactomApi\Facades\FactomDebugApi::class,
...
To publish the config file to app/config/factom-api.php
php artisan vendor:publish --provider="AdrianMejias\FactomApi\FactomApiServiceProvider"
This will publish a file factom-api.php
in your config directory with teh following content:
<?php
return [
/**
* Base credentials for Factom server.
*/
'url' => env('FACTOM_URL', 'http://localhost:8088/v2'),
'ssl' => [
'enable' => env('FACTOM_SSL', false),
'certificate' => env('FACTOM_CERTIFICATE', storage_path('app/factomdAPIpub.cert')),
],
'username' => env('FACTOM_USERNAME'),
'password' => env('FACTOM_PASSWORD'),
/**
* Factom wallet server credentials.
*/
'wallet' => [
'url' => env('FACTOM_WALLET_URL', 'http://localhost:8089/v2'),
'ssl' => [
'enable' => env('FACTOM_WALLET_SSL', false),
'certificate' => env('FACTOM_WALLET_CERTIFICATE', storage_path('app/factomdAPIpub.cert')),
],
'username' => env('FACTOM_WALLET_USERNAME'),
'password' => env('FACTOM_WALLET_PASSWORD'),
],
/**
* Factom debug server credentials.
*/
'debug' => [
'url' => env('FACTOM_DEBUG_URL', 'http://localhost:8088/debug'),
'ssl' => [
'enable' => env('FACTOM_DEBUG_SSL', false),
'certificate' => env('FACTOM_DEBUG_CERTIFICATE', storage_path('app/factomdAPIpub.cert')),
],
'username' => env('FACTOM_DEBUG_USERNAME'),
'password' => env('FACTOM_DEBUG_PASSWORD'),
],
];
After you've installed the package and filled in the values in the config-file working with this pacakge will be a breeze. All the following examples use the facade.
Route::get('/factom/heights', function() {
$result = FactomApi::heights();
return response()->json($result);
});
Replace Curl with GuzzleAdd Wallet methods- Add certificate auth
- Add unit tests
Run the tests with:
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.