PHP code example of jakobjohansson / kiwi

1. Go to this page and download the library: Download jakobjohansson/kiwi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jakobjohansson / kiwi example snippets



/*
 * 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');


/**
 * 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]);
}

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


$post->title = Input::field(
    'title',
    [
        'ers long.',
    ]
);

$post->save();