Skip to content

Instantly share code, notes, and snippets.

@kieraneglin
Last active February 20, 2018 20:20
Show Gist options
  • Save kieraneglin/9d3fffed6eeff73433e24d9fd4df8f0c to your computer and use it in GitHub Desktop.
Save kieraneglin/9d3fffed6eeff73433e24d9fd4df8f0c to your computer and use it in GitHub Desktop.
<?php
class PostsController {
public function show($params) { // Note that you have to accept an argument here to get param information
$post = Post.find($params['id']); // This param comes from the identifier we set in the route. Note that the `Post.find` is a fictional method
include 'views/posts/show.php';
}
public function index($params) {
// Format data is available! However, this only operates based on the content_type provided, and not by the format of the URL
if($params['format'] === 'json') {
include 'views/posts/index.json.php';
} else {
include 'views/posts/index.php';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment