Package Data | |
---|---|
Maintainer Username: | unicodeveloper |
Maintainer Contact: | prosperotemuyiwa@gmail.com (unicodeveloper) |
Package Create Date: | 2015-11-17 |
Package Last Update: | 2015-11-20 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-01 03:03:52 |
Package Statistics | |
---|---|
Total Downloads: | 12 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 3 |
Total Forks: | 1 |
Total Open Issues: | 1 |
Laravel 5 Package to work with Leanpub. Very easy to use. Offers the use of Facades and Dependency Injection
Disclaimer: Leanpub is a service of Ruboss Technology Corporation, a corporation incorporated in British Columbia, Canada. I self-publish a book using their service, but am otherwise not affiliated with them in any way.
PHP 5.5+ or HHVM 3.3+, and Composer are required.
First, pull in the package through Composer.
$ composer require unicodeveloper/laravel-leanpub
Another alternative is to simply add the following line to the require block of your composer.json
file.
"unicodeveloper/laravel-leanpub": "1.0.*"
Then run composer install
or composer update
to download it and have the autoloader updated.
Add this to your providers array in config/app.php
// Laravel 5: config/app.php
'providers' => [
...
Unicodeveloper\Leanpub\LeanpubServiceProvider::class,
...
];
This package also comes with a facade
// Laravel 5: config/app.php
'aliases' => [
...
'Leanpub' => Unicodeveloper\Leanpub\Facades\Leanpub::class,
...
]
Publish the config file by running:
php artisan vendor:publish
The config file will now be located at config/leanpub.php
.
This is the leanpub.php
file in the config
directory.
/**
* Config file that a developer can insert the api key from Leanpub
*/
return [
'API_KEY' => ''
];
You'll need your book slug and API key values, both of which can be retrieved by accessing your Leanpub account.
This is the class of most interest. It is bound to the ioc container as 'laravel-leanpub'
and can be accessed using the Facades\Leanpub
facade.
This facade will dynamically pass static method calls to the 'laravel-leanpub'
object in the ioc container which by default is the LeanpubManager
class.
Here you can see an example of just how simple this package is to use.
use Unicodeveloper\Leanpub\Facades\Leanpub;
// or you can alias this in config/app.php like I mentioned initially above
Book Summary Data
Leanpub::getBook($book_slug)->id;
// e.g sample $book_slug is phptherightway returns 11146
Leanpub::getBook($book_slug)->about_the_book;
// e.g sample $book_slug is phptherightway returns
<p><em>There is no canonical way to use PHP</em>. This website aims to introduce new PHP developers to some topics which they may not discover until it is too late, and aims to give seasoned pros some fresh ideas on those topics they’ve been doing for years without ever reconsidering. This ebook will also not tell you which tools to use, but instead offer suggestions for multiple options, when possible explaining the differences in approach and use-case.</p>\r\n
<p>This is a living document and will continue to be updated with more helpful information and examples as they become available.</p>
Leanpub::getBook($book_slug)->title;
// e.g sample $book_slug is phptherightway returns PHP: The "Right" Way
Leanpub::getBook($book_slug)->total_copies_sold;
// e.g sample $book_slug is phptherightway returns 12056
Leanpub::getBook($book_slug)->word_count_published;
// e.g sample $book_slug is phptherightway returns 15849
Leanpub::getBook($book_slug)->author_string;
// e.g sample $book_slug is phptherightway returns "Phil Sturgeon and Josh Lockhart"
Leanpub::getBook($book_slug)->url;
// e.g sample $book_slug is phptherightway returns "http://leanpub.com/phptherightway"
Leanpub::getBook($book_slug)->title_page_url;
// e.g sample $book_slug is phptherightway returns "https://s3.amazonaws.com/titlepages.leanpub.com/phptherightway/original?1425544606"
Leanpub::getBook($book_slug)->minimum_price;
// e.g sample $book_slug is phptherightway returns 0.0
Leanpub::getBook($book_slug)->suggested_price;
// e.g sample $book_slug is phptherightway returns 0.0
Leanpub::getBook($book_slug)->image;
// e.g sample $book_slug is phptherightway returns "https://s3.amazonaws.com/titlepages.leanpub.com/phptherightway/medium?1425544606"
Leanpub::getBook($book_slug)->isFree;
// e.g sample $book_slug is phptherightway returns true
Leanpub::getBook($book_slug)->last_published_at;
// e.g sample $book_slug is phptherightway returns "2015-01-05T16:37:01Z"
Leanpub::getBook($book_slug)->meta_description;
// e.g sample $book_slug is phptherightway returns null
Leanpub::getBook($book_slug)->page_count_published;
// e.g sample $book_slug is phptherightway returns 70
Leanpub::getBook($book_slug)->subtitle;
// e.g sample $book_slug is phptherightway returns "Your guide to PHP best practices, coding standards, and authoritative tutorials."
Leanpub::getBook($book_slug)->total_revenue;
// e.g sample $book_slug is phptherightway returns the price in revenue if the book is not free. For a book that is free like this, there is no `total_revenue` attribute
Leanpub::getBook($book_slug)->possible_reader_count;
// e.g sample $book_slug is phptherightway returns 12052
Sales Summary Data
Leanpub::getSalesInfo($book_slug)->book
Leanpub::getSalesInfo($book_slug)->url
Leanpub::getSalesInfo($book_slug)->total_author_royalties
Leanpub::getSalesInfo($book_slug)->total_book_royalties
Leanpub::getSalesInfo($book_slug)->num_happy_readers
Leanpub::getSalesInfo($book_slug)->num_happy_paid_purchases
Leanpub::getSalesInfo($book_slug)->num_refunded_purchases
Leanpub::getSalesInfo($book_slug)->unpaid_royalties
Leanpub::getSalesInfo($book_slug)->royalties_currently_due
Leanpub::getSalesInfo($book_slug)->royalties_due_on_first_of_next_month
Leanpub::getSalesInfo($book_slug)->paid_royalties
Add wrappers for other API functionalities:
Please see CHANGELOG for more information what has changed recently.
You can run the tests with:
vendor/bin/phpunit run
Alternatively, you can run the tests like so:
composer test
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
If you discover any security related issues, please email prosperotemuyiwa@gmail.com instead of using the issue tracker.