PHPackages                             jrean/blogit - 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. [Framework](/categories/framework)
4. /
5. jrean/blogit

ActiveLibrary[Framework](/categories/framework)

jrean/blogit
============

Blog with Git(hub). For Laravel 5.\*. Fetch and Parse Documents hosted on Github.

1.0.x-dev(9y ago)9711MITPHPPHP &gt;=5.5.9

Since May 21Pushed 9y ago2 watchersCompare

[ Source](https://github.com/jrean/blogit)[ Packagist](https://packagist.org/packages/jrean/blogit)[ RSS](/packages/jrean-blogit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

jrean/blogit
============

[](#jreanblogit)

**jrean/blogit** is a PHP wrapper for the Github API (not yet Framework Agnostic) built for Laravel/Lumen to publish easily your content and "Blog with Git".

Goals
-----

[](#goals)

- Leverage the power of the Github API
- No database, no backoffice, no forms, ...
- Open source your content and allow easy contributions
- Write, Commit, Push, Live...

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

[](#installation)

This project can be installed via [Composer](http://getcomposer.org)To get the latest version of Blogit, simply add the following line to the require block of your composer.json file:

```
"jrean/blogit": "~0.1.0"
// or
"jrean/blogit": "dev-master"

```

You'll then need to run `composer install` or `composer update` to download it and have the autoloader updated.

### Add the Service Provider

[](#add-the-service-provider)

Once Blogit is installed, you need to register the service provider.

#### Laravel

[](#laravel)

Open up `config/app.php` and add the following to the `providers` key:

- `'Jrean\Blogit\BlogitServiceProvider'`

#### Lumen

[](#lumen)

Open up `bootstrap/app.php` and add the following:

- `$app->register('Jrean\Blogit\BlogitServiceProvider');`

### Enable Dotenv File (Lumen only)

[](#enable-dotenv-file-lumen-only)

Uncomment the following line in `bootstrap/app.php`:

```
// Dotenv::load(__DIR__.'/../');

```

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

[](#configuration)

Update your `.env` file with the following keys and assign your values:

```
GITHUB_USER                    =your_github_user_name
GITHUB_TOKEN                   =your_github_token
GITHUB_REPOSITORY              =your_repository_name
GITHUB_ARTICLES_DIRECTORY_PATH =content_root_directory_name

```

- `GITHUB_TOKEN`

Your Github username.

- `GITHUB_TOKEN`

Visit [Github](https://github.com/settings/tokens) and create a `Personal Access Tokens`

- `GITHUB_REPOSITORY`

Create a new `Public` repository or use an existing one.

- `GITHUB_ARTICLES_DIRECTORY_PATH`

Inside your repository create a directory (for instance `articles`) where you will push your files.

Basic usage
-----------

[](#basic-usage)

### Without Controller

[](#without-controller)

Update `app/Http/routes.php`:

```
$app->get('/blogit', function() use($app) {

    // Jrean\Blogit\Blogit instance
    $blogit   = $app->make('blogit');

    // Jrean\Blogit\BlogitCollection
    $articles = $blogit->getArticles();

    // Last 3 created Articles
    $news     = $articles->sortByCreatedAtDesc()->take(3);

    // Last 3 updated Articles
    $updates  = $articles->sortByUpdatedAtDesc()->take(3);

    return view('blogit.index', compact('news', 'updates')); });

$app->get('/blogit/{slug}', function($slug) use($app) {

    // Jrean\Blogit\Blogit instance
    $blogit  = $app->make('blogit');

    // Jrean\Blogit\Document\Article
    $article = $blogit->getArticleBySlug($slug);

    if ($article === null) abort(404);

    return view('blogit.show', compact('article'));
});

```

### With Controller

[](#with-controller)

Update `app/Http/routes.php`:

```
$app->get('/', [
    'uses' => 'App\Http\Controllers\YourController@index',
    'as'   => 'index'
]);

$app->get('/{slug}', [
    'uses' => 'App\Http\Controllers\YourController@show',
    'as'   => 'show'
]);

```

Update `app/Http/Controllers/YourController.php`:

```
