crypto-technology/laravel-cryptocurrency

Laravel provider to have all cryptocurrency infos in a single package without using a database.

v0.1 2019-03-22 18:00 UTC

This package is auto-updated.

Last update: 2024-11-11 21:32:17 UTC


README

Latest Version on Packagist Total Downloads Build Status Last commit License Requires PHP7.1

Laravel provider to have all cryptocurrency infos in a single package without using a database.

Installation

$ composer require crypto-technology/laravel-cryptocurrency

Laravel 5.5+

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php:

'providers' => [
    ...
    CryptoTech\Laravel\CryptocurrencyServiceProvider::class,
    ...
],

If you want to use the facade, add the Facade to the facades array in config/app.php:

'aliases' => [
    ...
    'Cryptocurrency' => CryptoTech\Laravel\Facades\Cryptocurrency::class,
    ...
]

Copy the package config to your local config with the publish command:

$ php artisan vendor:publish --provider="CryptoTech\Laravel\CryptocurrencyServiceProvider"

Lumen

Configure the Service Provider and alias:

# boostrap/app.php

// Register the facade
$app->withFacades(true, [
    CryptoTech\Laravel\Facades\Cryptocurrency::class => 'Cryptocurrency'
]);

// Load the configuration
$app->configure('cryptocurrency');

// Register the service provider
$app->register(CryptoTech\Laravel\CryptocurrencyServiceProvider::class);

Copy the configuration file to /config/cryptocurrency.php if you wish to override it.

Usage

First, make sure that interested cryptocurrency is enabled in your /config/cryptocurrency.php config file.
All methods available on \CryptoTech\Cryptocurrency\Cryptocurrency class can be used in this package.

# HomeController.php

use Cryptocurrency;

// Get the Bitcoin object
$bitcoin = Cryptocurrency::get('Bitcoin');

// Return (string) cryptocurrency name
$bitcoin->getName();

// Return (string) cryptocurrency description
$bitcoin->getDescription();

// Return (boolean) cryptocurrency mineable state
$bitcoin->isMineable();

return view('home', compact('bitcoin'));
# home.blade.php

@section('content')
    <p>{!! $bitcoin->getSymbol() !!}</p>
@endsection

More information can be found in the \CryptoTech\Cryptocurrency\CryptocurrencyInterface interface PhpDocumentation.
The \CryptoTech\Cryptocurrency\Cryptocurrency class contains, in addition to the get methods, also set methods (only for description and for project, explorer and sourcecode urls), which allow you to momentarily overwrite the default values.

Changelog

Please see the CHANGELOG for more information on what has changed recently.

Testing

# For Windows system
$ composer test-win

# For Unix system
$ composer test-unix

Contributing

Your help is always welcome! Feel free to open issues, ask questions, talk about it and discuss this tool.
Of course there are some contributing guidelines and a code of conduct, which I invite you to check out.
For all other contributions, see below.

After every code changes, but before submit your pull request, please apply Php Cs Fixer code fixing:

# For Windows system
$ composer php-cs-fixer-win

# For Unix system
$ composer php-cs-fixer-unix

Security

The CryptoTech\Laravel package will be checked for security vulnerabilities using Roave Security Advisories checker. If you discover any security related issues, please email security@cryptotech.srl instead of using the issue tracker.

Code

Credits

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

The GNU General Public License version 3. Please see the license file for more information. This work is licensed under the GNU GPL v3.