Last active
February 20, 2018 20:20
-
-
Save kieraneglin/9d3fffed6eeff73433e24d9fd4df8f0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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