<?php

namespace Examples\blog\APP\Controllers;

use Phramework\Phramework;
use Phramework\Validate\Validate;
use Phramework\Models\Request;
use Examples\blog\APP\Models\Post;

class PostController
{
    public static function GET($params, $method, $headers)
    {
        /*if (($id = Request::resourceId($params)) !== FALSE) {
            echo '<pre>';
            print_r([$params, $method, $headers]);
            echo '</pre>';
            throw new \Phramework\Exceptions\NotImplemented();
        }*/

        $posts = Post::getAll();

        Phramework::view([
            'posts' => $posts,
        ], 'blog', 'My blog'); //will load viewers/page/blog.php
    }

    public static function GETSingle($params, $method, $headers)
    {
        $id = Request::requireId($params);

        $posts = Post::getAll();

        array_unshift($posts, []);

        if ($id == 0 || $id > count($posts) - 1) {
            throw new \Phramework\Exceptions\NotFound('Post not found');
        }

        Phramework::view([
            'posts' => [$posts[$id]],
        ], 'blog', 'My blog #' . $id); //will load viewers/page/blog.php
    }
}

<?php

namespace Examples\blog\APP\Controllers;

use Phramework\Phramework;
use Phramework\Validate\Validate;
use Phramework\Models\Request;
use Examples\blog\APP\Models\Post;

class PostController
{
    public static function GET($params, $method, $headers)
    {
        /*if (($id = Request::resourceId($params)) !== FALSE) {
            echo '<pre>';
            print_r([$params, $method, $headers]);
            echo '</pre>';
            throw new \Phramework\Exceptions\MissingParametersException\NotImplemented();
        }*/

        $posts = Post::getAll();

        Phramework::view([
            'posts' => $posts,
        ], 'blog', 'My blog'); //will load viewers/page/blog.php
    }

    public static function GETSingle($params, $method, $headers)
    {
        $id = Request::requireId($params);

        $posts = Post::getAll();

        array_unshift($posts, []);

        if ($id == 0 || $id > count($posts) - 1) {
            throw new \Phramework\Exceptions\NotFoundException('Post not found');
        }

        Phramework::view([
            'posts' => [$posts[$id]],
        ], 'blog', 'My blog #' . $id); //will load viewers/page/blog.php
    }
}

Change all Exception classes with Exceptions suffix
Change all Exception classes with Exceptions suffix

Allow array to be set as method argument in URITemplate
