PHP Classes
elePHPant
Icontem

OBPipe: Manipulate PHP output with named pipe buffers

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2014-07-27 (11 months ago) RSS 2.0 feedStarStarStarStar 66%Total: 341 All time: 6,462 This week: 1,205Up
Version License PHP version Categories  
obpipe 1.0GNU General Publi...5.0PHP 5, Content management
Description Author  

This class can manipulate PHP output with named pipe buffers.

It can capture PHP script output and store it in one or more buffer variables associated with given names.

The class can reorder, disable and manipulate the buffered output before sending it to the browser.

Innovation Award  
PHP Programming Innovation award nominee
April 2011
Number 9
The layout of some site pages may be sorted according to user preferences. A page section may appear in a different position.

This class allows you to capture the output of different parts of the code that generates the output of each section and lets you rearrange the page layout the way you want.

Manuel Lemos
Picture of Thomas Björk
Name: Thomas Björk <contact>
Classes: 11 packages by
Country: Sweden Sweden
Age: 47
All time rank: 1661 in Sweden Sweden
Week rank: 97 Up1 in Sweden Sweden Equal
Innovation award
Innovation award
Nominee: 3x

Details provided by the author  

OBPipe

OBPipe and SOBPipe are two classes that allows you to handle output buffering as if you were writing to different pipes. This makes it possible to reorder the output before it is actually written.

class OBPipe

public function kill()

Terminate the ob_handler

public function activate($name)

Select which pipe to write to

public function current()

Get the name of the current pipe

public function clean($name)

Clean the named pipe

public function remove($name)

Remove the named pipe

protected function getBuffer()

Internal function that collects the data from the ob_handler and puts it in the correvt pipe

public function flush($name)

Returns the content of the named pipe and empties its content

public function get($name)

Return the content of the named pipe without changing its content

public function length($name)

Returns the length if the string in the specified pipe

public function Output($result)

Collects the complete output stored in all pipes

public function getNames()

Get the names of all pipes

public function setNames($names)

Assign which pipes should exist and in which order. Any existing pipe will be intact and any new pipe will be created. If a pipe doesn't exist in the array then its content will be removed.

class SOBPipe

SOBPipe is a static wrapper for the OBPipe

public static function Init()

Make sure there is an instance to work with. This is called by an function so there is really no need to call it explicitly

public static function activate($name)

Activate the given named pipe. Will be created if it doesn't exist

public static function current()

Return the name of the current pipe

public static function clean($name)

Remove the content from the named pipe

public static function remove($name)

Remove the named pipe. Any content will be removed

public static function flush($name)

Return the content of the named pipe. The content will be removed from the handler

public static function get($name)

Return the content of the named pipe. The content will be unchanged in the handler

public static function length($name)

Return the length of the named pipe

public static function getNames()

Return the name of all pipes

public static function setNames($names)

Set the order of the pipes in the handler. Any named pipe that doesn't exist will be created and any pipe that isn't listed will be removed

public static function kill()

Terminate the static handler

If the name of a pipe is false (boolean) an unnamed pipe will be used instead. The content of the unnamed pipe will always be presented before the content of the named handlers.

Simple usage - Dynamic

<?php
include('../obpipe.php');
$pipe = new OBPipe();
$pipe->activate('alpha');
echo "Hello";
$pipe->activate('bravo');
echo ", world!";
?>

Will print "Hello, world!"

  Files folder image Files  
File Role Description
Files folder imagedemo (7 files)
Files folder imagedoc (1 file)
Accessible without login Plain text file LICENSE Data License file
Plain text file obpipe.php Class The main class
Accessible without login Plain text file README.md Data Updated readme to markdown

  Files folder image Files  /  demo  
File Role Description
  Accessible without login Plain text file helloworld.php Example A simple Hello, world! demo
  Accessible without login Plain text file helloworld2.php Example A simple Hello, world! demo
  Accessible without login Plain text file helloworld3.php Example A simple Hello, world! demo
  Accessible without login Plain text file html.php Example A simple demo of creating an html page
  Accessible without login Plain text file html2.php Example A simple demo of creating an html page
  Accessible without login Plain text file html3.php Example A simple demo of creating an html page
  Accessible without login Plain text file html4.php Example A simple demo of creating an html page

  Files folder image Files  /  doc  
File Role Description
  Accessible without login Plain text file obpipe.doc Doc. A simple documentation

 Version Control Unique User Downloads Download Rankings  
 100%Total:341All time:6,462
 This week:0This week:1,205Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:66%StarStarStarStar
Documentation:66%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:430