PHPackages                             unicodeveloper/laravel-leanpub - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. unicodeveloper/laravel-leanpub

ActiveLibrary

unicodeveloper/laravel-leanpub
==============================

A Leanpub Package for Laravel 5

1.0.1(10y ago)2131[1 issues](https://github.com/unicodeveloper/laravel-leanpub/issues)MITPHPPHP &gt;=5.3.0

Since Nov 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/unicodeveloper/laravel-leanpub)[ Packagist](https://packagist.org/packages/unicodeveloper/laravel-leanpub)[ Docs](https://twitter.com/unicodeveloper)[ RSS](/packages/unicodeveloper-laravel-leanpub/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

laravel-leanpub
===============

[](#laravel-leanpub)

[![Latest Stable Version](https://camo.githubusercontent.com/48ad495bb95a032ae6cd9c645aba7a8db825997767644eeb87eb4abfb775bb5e/68747470733a2f2f706f7365722e707567782e6f72672f756e69636f646576656c6f7065722f6c61726176656c2d6c65616e7075622f762f737461626c652e737667)](https://packagist.org/packages/unicodeveloper/laravel-leanpub)[![License](https://camo.githubusercontent.com/cee49a6be371e064de43e8b367d486847f98afa3b66ce73939799f67ebe13f17/68747470733a2f2f706f7365722e707567782e6f72672f756e69636f646576656c6f7065722f6c61726176656c2d6c65616e7075622f6c6963656e73652e737667)](LICENSE.md)[![](https://camo.githubusercontent.com/984f6792e3d81e34b782c12770dfd5e6153ea75f5e71d8e668933b988ba1a81f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f756e69636f646576656c6f7065722d617070726f7665642d627269676874677265656e2e737667)](https://camo.githubusercontent.com/984f6792e3d81e34b782c12770dfd5e6153ea75f5e71d8e668933b988ba1a81f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f756e69636f646576656c6f7065722d617070726f7665642d627269676874677265656e2e737667)[![Build Status](https://camo.githubusercontent.com/a2eb80679c9ea98d1282ef75dc1d430d6df94d7e3fbc699a3e5980a271984f81/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f756e69636f646576656c6f7065722f6c61726176656c2d6c65616e7075622e737667)](https://travis-ci.org/unicodeveloper/laravel-leanpub)[![Quality Score](https://camo.githubusercontent.com/c979443a83ecb816f9de29d83d376c988b3e11150b2a8df8a924ec33647cfa2f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f756e69636f646576656c6f7065722f6c61726176656c2d6c65616e7075622e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/unicodeveloper/laravel-leanpub)[![Total Downloads](https://camo.githubusercontent.com/757afc62e5f41c101ae5ba559a73b4298b546f7e38f15dd968f1184af307a30b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f756e69636f646576656c6f7065722f6c61726176656c2d6c65616e7075622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unicodeveloper/laravel-leanpub)

> 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.

Installation
------------

[](#installation)

[PHP](https://php.net) 5.5+ or [HHVM](http://hhvm.com) 3.3+, and [Composer](https://getcomposer.org) 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`.

Configuration
-------------

[](#configuration)

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' => ''
];
```

Usage
-----

[](#usage)

You'll need your book slug and API key values, both of which can be retrieved by [accessing your Leanpub account](https://leanpub.com/dashboard).

##### LeanpubManager

[](#leanpubmanager)

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.

##### Facades\\Leanpub

[](#facadesleanpub)

This facade will dynamically pass static method calls to the `'laravel-leanpub'` object in the ioc container which by default is the `LeanpubManager` class.

##### Examples

[](#examples)

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

 There is no canonical way to use PHP. 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.\r\n
 This is a living document and will continue to be updated with more helpful information and examples as they become available.

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
```

TODO
----

[](#todo)

Add wrappers for other API functionalities:

- All sales data
- Preview functions
- Publish functions
- Preview/publish job status
- Coupon management
- Testing

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

You can run the tests with:

```
vendor/bin/phpunit run
```

Alternatively, you can run the tests like so:

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Prosper Otemuyiwa](https://twitter.com/unicodeveloper)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Security
--------

[](#security)

If you discover any security related issues, please email [prosperotemuyiwa@gmail.com](prosperotemuyiwa@gmail.com) instead of using the issue tracker.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3823d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae318eb1f5f21579ddee07834130c1169ae6a0771044c3de671dfb02cd79c59f?d=identicon)[unicodeveloper](/maintainers/unicodeveloper)

---

Top Contributors

[![unicodeveloper](https://avatars.githubusercontent.com/u/2946769?v=4)](https://github.com/unicodeveloper "unicodeveloper (14 commits)")

---

Tags

phplaravelpackagelaravel 5Bridgeunicodeveloperleanpublaravel-leanpub

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/unicodeveloper-laravel-leanpub/health.svg)

```
[![Health](https://phpackages.com/badges/unicodeveloper-laravel-leanpub/health.svg)](https://phpackages.com/packages/unicodeveloper-laravel-leanpub)
```

###  Alternatives

[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162145.5k1](/packages/joisarjignesh-bigbluebutton)[victorybiz/geoip-location

Get the geographical location of website visitors based on their IP addresses. Support Laravel and PHP (Non-Laravel) Project.

22157.9k2](/packages/victorybiz-geoip-location)[martian/spammailchecker

A laravel package that protect users from entering non-existing/spam email addresses.

422.0k](/packages/martian-spammailchecker)[wujunze/money-wrapper

MoneyPHP Wrapper

113.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
