for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Http\HttplugBundle\Collector\Twig;
/**
* @author Tobias Nyholm <[email protected]>
*/
class HttpMessageMarkupExtension extends \Twig_Extension
{
* {@inheritdoc}
*
* @return array
public function getFilters()
return [
new \Twig_SimpleFilter('httplug_markup', [$this, 'markup'], ['is_safe' => ['html']]),
];
}
* @param string $message http message
public function markup($message)
$safeMessage = htmlentities($message);
list($headers, $body) = preg_split('|\\r?\\n\\r?\\n|', $safeMessage, 2);
// make header names bold
$headers = preg_replace("|\n(.*?): |si", "\n<b>$1</b>: ", $headers);
return sprintf("%s\n\n<div class='httplug-http-body'>%s</div>", $headers, $body);
public function getName()
return 'httplug.message_markup';