Leaf tries as much as possible to use raw PHP written from scratch, so, instead of using PSR-7 like most frameworks do, Leaf has written predefined response methods.
In v1.3, Request is now part of the HTTP namespace.
To include the Response object in a route, use this:
Responseclass, and we pass it into the route with
Response MethodsIn v1.3, Response methods no longer use the
echokeyword. Everything is handled in Response.
Respond is a method built for APIs and direct responses to the user. This response is encoded as JSON and output as such
RespondWithCode is also a method built for APIs and direct responses to the user. This response is encoded as JSON and output as such, but it includes a section for the http code(default is 200)
throwErr is also a method built for APIs and direct responses to the user, however, this method is suitable for errors only.
The response is encoded as JSON and output as such, also, the correct headers are set for the error. It also includes a section for the http error code.
More info on http status codes here
In v1.4.2, renderHtmlPage has been renamed to renderHtml for clarity and simplicity.
renderHtml is a method built for websites and webapps. This method is can be used with the routing to achieve server side routing, for example:
/homepageis invoked, Leaf loads up
home.htmland outputs it to the user
renderMarkup is another method built for websites and webapps. This method outputs any html entered into it with a content type of text/html:For instance, with this code,
Next StepsSimple Routing