Manager of PHP output buffers

v1.0.0 2014-12-03 07:59 UTC

This package is auto-updated.

Last update: 2024-04-13 09:30:55 UTC


A simple manager for PHP output buffers. Can manage named or unnamed buffers.


The most common useage for this class is named output buffers, so that you can buffer multiple pieces of a page and then output them later in specific places.

$bufferManager = new TJM\Component\BufferManager\BufferManager();

echo 'This is in block 1';

echo 'This is in block 2';
<div class="wrapper">
	<h2>This is block 1's heading</h2>
	<div class="block1"><?php echo $bufferManager->get('block1'); ?></div>
	<h2>This is block 2's heading</h2>
	<div class="block2"><?php echo $bufferManager->get('block2'); ?></div>

Here is an example for an HTML document, illustrating how it might be used to output the buffers in an HTML document, or in a JSON representation of that document if the request is via AJAX.


	echo json_encode(Array(
		'title'=> $pagetitle
		,'main'=> $bufferManager->get('main')
		,'aside'=> $bufferManager->get('aside')
<!DOCTYPE html>