2017 © Pedro Peláez
 

project kiwi

a minimalistic and lightweight blog framework

image

jakobjohansson/kiwi

a minimalistic and lightweight blog framework

  • Wednesday, October 4, 2017
  • by jakobjohansson
  • Repository
  • 2 Watchers
  • 2 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

kiwi Packagist Codacy Badge StyleCI

kiwi is a minimalistic and lightweight blog framework for php., (*1)

Documentation

Kiwi can be installed via Composer:, (*2)

composer create-project jakobjohansson/kiwi

Configuration

Included in the package is a .env.example file, which should be renamed to .env and omitted from version control. It is a simple environment file containing fields for database settings, user settings and more general application settings. Kiwi will not run without this file., (*3)

After this is done, you should head to the /migrate route to migrate the default SQL tables., (*4)

Routes

Custom routes can be set in the app/routes.php file, pointing a route towards a controller and a target method:, (*5)

<?php
/*
 * Routes file.
 * You can create your own custom routes in here, at the end of this file.
 */

 $router->get('', 'PageController/index');
 $router->get('post/{id}', 'PageController/show');

Controllers

All controllers reside in the app/Controllers directory. An example controller is included with the following methods:, (*6)

<?php
/**
 * Render the main page.
 *
 * @return void
 */
public function index()
{
    View::render('index', ['posts' => Post::all()]);
}

/**
 * Render a specific post page.
 *
 * @param Post $post
 *
 * @return void
 */
public function show(Post $post)
{
    if (!$post) {
        throw new HttpException("That post doesn't exist.");
    }

    View::render('post', ['post' => $post]);
}

Notice the type hinted Post parameter in the show method. It will be automatically injected when you provide a wildcard in your route!, (*7)

Middleware

You can apply custom middleware by creating a middleware() method in your controller. It will run on every request directed towards the controller., (*8)

Views

As seen in the example above, views can be requested from a controller method by stating View::render($viewpath, $arrayOfData). The view path is relative to the app/Views folder, with a suffixed .view.php added at the end, meaning you can simply enter the file name., (*9)

Templating

Kiwi supports templating similar to that of Laravel Blade:, (*10)

<div class="content">
    @foreach ($posts as $post)
        <h3 class="subtitle is-4">
            <a href="/post/{{$post->id}}">
                {{$post->title}}
            </a>
        </h3>
        <div class="content">
            {{nl2br($post->body)}}
        </div>
        <footer>
            <small>Written {{$post->created_at}}.</small>
        </footer>
    @endforeach
</div>

At the time of writing, the following directives are supported: - if / elseif / else statements - echo expressions - foreach loops - includes, (*11)

Validation

Validation is rather simple with kiwi. Simply access a form field using the Input class, which takes the field name as the first parameter and an array of rules as the second parameter:, (*12)

<?php
$post->title = Input::field(
    'title',
    [
        'required' => 'The title is required.',
        'min:3'    => 'The title needs to be atleast 3 characters long.',
    ]
);

$post->save();

The supported rules can be found in the Rule class. At the time of writing, the following rules are supported: - min - max - required - email - url - digits - alpha, (*13)

If validation fails, kiwi will redirect back with access to an $errors variable, containing all the data you need to display an informative error message!, (*14)

License

Kiwi is MIT licensed, meaning you are free modify and do as you wish with the code., (*15)

The Versions

04/10 2017

dev-master

9999999-dev https://github.com/jakobjohansson/kiwi

a minimalistic and lightweight blog framework

  Sources   Download

MIT

The Requires

  • php ^7.0

 

framework lightweight minimal blog

28/09 2017

v0.0.6

0.0.6.0 https://github.com/jakobjohansson/kiwi

a minimalistic and lightweight blog framework

  Sources   Download

MIT

The Requires

  • php ^7.0

 

framework lightweight minimal blog

21/09 2017

v0.0.5

0.0.5.0

  Sources   Download

15/09 2017

v0.0.4

0.0.4.0

  Sources   Download

12/09 2017

v0.0.3

0.0.3.0

  Sources   Download

08/09 2017

v0.0.2

0.0.2.0

  Sources   Download

05/09 2017

v0.0.1

0.0.1.0

  Sources   Download