News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso's Blog:
Using a stream wrapper to access CouchDb attachments with PHP
September 06, 2010 @ 08:15:22

In his continuing look at using CouchDb as a file system, Gonzalo Ayuso has posted this third part in the group of articles about using streams to connect your scripts to the database instance.

I'm still working in my filesystem with CouchDb. After creating a library to enable working with PHP and CouchDB (see the post here), and after using Monkey Patching to override standard PHP's filesystem functions. I've created another solution now. Thanks to a comment in my last post (many thanks Benjamin) I've discovered that it's possible to create a stream wrapper in PHP (I thought it was only available with a C extension).

He includes the code for the stream connection wrapper, a pretty simple script that parses the string it's given and opens a read/write stream to the source. There's also a "url_stat" method that will return to you the size of the stream in bytes. Then you just register the wrapper and go about your normal file system calls to use the CouchDb directly.

0 comments voice your opinion now!
couchdb stream wrapper attachment tutorial


blog comments powered by Disqus

Similar Posts

Pádraic Brady's Blog: The Factory and Abstract Factory patterns in PHP

Artur Ejsmont's Blog: How to build mongodb pecl extension in 32bit for PHP 5.2 on OSX Snow Leaopard

PHPMaster.com: PHP Security: Cross-Site Scripting Attacks (XSS)

Alex Netkachov's Blog: File stream wrapper is overwritable in PHP

Zend Developer Zone: AJAX Chat Tutorial Part 6 : Updating the User List


Community Events





Don't see your event here?
Let us know!


version security symfony voicesoftheelephpant release framework application introduction series community composer language library podcast install tool laravel package opinion interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework