Skip to content

Instantly share code, notes, and snippets.

@hgraca
Last active August 22, 2018 13:29
Show Gist options
  • Save hgraca/5dce8b6a83ada60c2203fe413b401ca3 to your computer and use it in GitHub Desktop.
Save hgraca/5dce8b6a83ada60c2203fe413b401ca3 to your computer and use it in GitHub Desktop.
RMR - Resource-Method-Representation pattern
<?php
// taken from http://www.peej.co.uk/articles/rmr-architecture.html
class Resource {
private resourceData = [];
method constructor(request, dataSource) {
// load data from data source
}
method get(request) {
return new Response(200, getRepresentation(request.url, resourceData));
}
method put(request) {
return new Response(405);
}
method post(request) {
return new Response(405);
}
method delete(request) {
return new Response(405);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment