PHP Classes

OBPipe: Manipulate PHP output with named pipe buffers

Recommend this page to a friend!
  Info   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (2 months ago) RSS 2.0 feedStarStarStar 59%Total: 354 This week: 1All time: 6,959 This week: 571Up
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
  Performance   Level  
Name: Thomas Björk <contact>
Classes: 11 packages by
Country: Sweden Sweden
Age: 55
All time rank: 1581 in Sweden Sweden
Week rank: 103 Up2 in Sweden Sweden Down
Innovation award
Innovation award
Nominee: 3x

Details

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:354
This week:1
All time:6,959
This week:571Up
 User Ratings  
 
 All time
Utility:80%StarStarStarStarStar
Consistency:65%StarStarStarStar
Documentation:60%StarStarStarStar
Examples:70%StarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1276