News Feed
Sections




News Archive
feed this:

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

Michael Dowling:
A Case for Higher Level PHP Streams in PSR-7
July 15, 2014 @ 10:54:53

In his latest post Michael Dowling looks at a recently proposed PSR standard (the HTTP message one, created by him) and some of his thoughts around it and what it could do for the community.

There's been a lot of talk lately about the PSR HTTP message proposal, PSR-7. The purpose of the proposal is to create a shared interface that can be used by projects to interact with HTTP messages for both clients and servers. When I created the proposal, I envisioned the purpose is not to say projects that utilize HTTP messages need to make breaking changes to use the proposed interfaces, but rather give projects an interface for which they can create an adapter.

He points out that the major part of the proposal that's being debated is the message body methods and structure. He gives a quick overview of this API and how streams could fit in with it, providing a flexible abstraction layer over the actual data. He includes a few ideas for some functionality that could make streams work relatively easily with the proposal (using a StreamInterface):

  • No Auto-registering of stream protocols and filters
  • Exceptions cause warnings in stream wrappers and filters
  • Functionality is spread over many functions

He also shares an example (based around the Guzzle HTTP library) showing how this interface could be put to work. He also talks some about one of the major concerns voiced right now, getting the actual stream itself to work with, and shows how the "detach" method matches this goal.

0 comments voice your opinion now!
usecase streams highlevel psr7 proposal http

Link: http://mtdowling.com/blog/2014/07/03/a-case-for-higher-level-php-streams/

Docnet.nu:
SSL And PHP Streams - Part 1 You Are Doing It Wrong™
June 26, 2014 @ 09:54:40

On the Docnet.nu blog today they've kicked off a series looking at the use of streams and SSL in PHP and asking if you're doing it wrong in your current applications. The focus is more on the security aspect, breaking it down into a set of common problems (and how to work around them).

The upcoming PHP 5.6 release brings with it a number of improvements to encrypted PHP streams, both internally and externally. In these articles I will try to cover the most important changes, and how they affect your code. This article will focus on how to get the best security level in code that needs to be run on PHP versions below 5.6, and highlighting some of the gaps in the currently available functionality. Version 5.4.13 is the earliest version that supports all the options described below - and if you are running something earlier than this, then you really should consider upgrading to at least the latest version of the 5.4 series 1.

Their list is made up of six different problems:

  • Problem 1: Peer Verification
  • Problem 2: Cipher Lists
  • Problem 3: Protocol Support
  • Problem 4: TLS Compression Attack Vulnerability
  • Problem 5: Cipher Order
  • Problem 6: TLS Renegotiation Attacks

Each problem comes with a brief description of what it is and why it's an issues. Some also include code snippets showing how to correct the issue, usually relatively simply.

0 comments voice your opinion now!
streams problem list solution https tutorial

Link: http://www.docnet.nu/tech-portal/2014/06/26/ssl-and-php-streams-part-1-you-are-doing-it-wrongtm/C0

SitePoint PHP Blog:
Using PHP Streams Effectively
November 21, 2013 @ 11:54:02

Vito Tardia has a new tutorial posted to the SitePoint PHP blog today showing you how to use PHP streams effectively, a continuation of his streams series started here.

n my previous article we've discovered the basics of PHP Streams and how powerful they were. In this tutorial we are going to use this power in the real world. First I'll show you how to build your custom filters and attach them to a stream, then we'll package our filters inside a document parser application.

He starts out by introducing the concept of filters in streams - bits of code that can be attached to the stream to perform operations on the data traveling through it. He includes a simple base64 encoding example with a fopen call to illustrate. He gets into more complex filtering by creating a Markdown filter capable of translating the incoming Markdown-formatted data into a document using the MarkdownExtra library. He also includes an example of another filter added on post-Markdown conversion, a Template filter using the RainTPL templating library.

0 comments voice your opinion now!
using streams filter markdown template tutorial

Link: http://www.sitepoint.com/using-php-streams-effectively/

Hannes Magnusson:
PHP Stream Notifications <3 MongoDB
September 17, 2013 @ 09:02:54

In this latest post to his site, Hannes Magnusson looks briefly at an interesting use for PHP's streams functionality - reading data from a MongoDB connection as a streaming resource.

PHP Streams have several pretty nifty features that most people don't really know about; Filters, Wrappers, Context, and Notifications. Documenting these is a bit difficult, and getting the user to discover these features is even more problematic, as these things usually live outside of the normal path (function reference). Maybe I'll blog about these things in the future, but for now I want to talk about the Stream (context) Notifications - or more specifically; Stream Notifications in the MongoDB extension for PHP.

He talks some about what stream notifications are on a basic level and some general use cases for them. From there he moves into the MongoDB world and some changes in the mongodb 1.4 extension over to using streams. He also talks about some of the things coming in the 1.5 version including progress reporting for read/write actions.

0 comments voice your opinion now!
mongodb streams extension nosql notification

Link: http://bjori.blogspot.com/2013/09/php-stream-notifications-mongodb.html

PHPMaster.com:
Understanding Streams in PHP
June 26, 2013 @ 10:43:45

PHPMaster.com has a new tutorial for those interested in how to work with streams, he base resources behind working with things like files and remote connections.

Streams are resources provided by PHP that we often use transparently, but which can also be very powerful tools. By learning how to harness their power, we can take our applications to a higher level. [...] Every stream has a implementation wrapper which has the additional code necessary to handle the specific protocol or encoding. PHP provides some built-in wrappers and we can easily create and register custom ones. We can even modify or enhance the behavior of wrappers using contexts and filters.

They start by introducing two of the most commonly used streams - "file" and "http" as well as some of the wrappers that can be used to work with them. He also talks about the "php://" stream, a special instance that lets you access things like a temporary memory block and stdout/stdin. He finishes up the tutorial with a look at "contexts" - the parameters that can be used to modify the stream wrapper (like his HTTP example).

0 comments voice your opinion now!
tutorial streams introduction file http internal

Link: http://phpmaster.com/%EF%BB%BFunderstanding-streams-in-php

Wojciech Sznapka's Blog:
Power of PHP streams - decompress gz archives on the fly from remote server
November 24, 2010 @ 08:39:05

Wojciech Sznapka has a new post to his blog today looking at the "power of PHP streams" and how they can be used to decompress gzipped data from remote servers.

Probably most of us heard about streams in PHP. They are background of all files and network operations in PHP, even if we don't see it. Everytime when you use file_get_contents or fopen you are actually using streams. But there are many stream wrappers I haven't used, because they aren't well known.One of them is compress.zlib (and two other compression stream filters).

He includes a quick example (because, thankfully, that's all working with streams like this usually requires) about pulling in a file from his server and uses the stream to fetch and unzip the data to display the contents.

0 comments voice your opinion now!
streams tutorial gzip decompress archive


Kevin Schroeder's Blog:
You want to do WHAT with PHP? Chapter 4
September 02, 2010 @ 13:49:23

Kevin Schroeder has another new post to his blog today with an excerpt from his "You Want to Do WHAT with PHP?" book. This new post is a section from the fourth chapter looking at stream handling.

Communication is key to building applications now and for the future. While it is not something that I think that everyone should do, I have not seem many applications that make good use of streams in PHP. Streams can be immensely useful in the right situations, but a lot of developers are not really aware of how streams can be used. [...] While I don't think you will end up basing your application around streams it is a really good idea to know how streams work.

The sample code (and description) talk about changing the properties of a stream on the fly. He shows how, with a fgets loop checking the input, he can catch a command from the already running script and change the compression setting on the currently open stream. The compression changes the stream's data from plain text to a binary format as handled by the streams functionality.

1 comment voice your opinion now!
book excerpt kevinschroeder streams


Davey Shafik's Blog:
Avoiding EVAL()
February 02, 2009 @ 11:15:24

Davey Shafik has a helpful hint for avoiding one of the worst functions to use in PHP - eval.

There are a shed-load of ways to "eval()" code without actually calling the eval() function '" usually done simply to avoid the use of the dreaded "evil()" function, but often times because the system has eval() disabled using "disable_functions" in php.ini. Here is another simple way to avoid eval() without writing out files to the filesystem

His example uses the streams wrapper to natively execute the code from a string variable as a data element, base64 decoded. It's more of a proof-of-concept than anything else, but its an interesting solution to a tough problem to solve at times.

0 comments voice your opinion now!
eval evil avoid streams wrapper data base64 execute


Matthew Turland's Blog:
Benchmarking PHP HTTP Clients
November 24, 2008 @ 07:56:30

Matthew Turland has this new blog post looking at some benchmarks he's generated for a group of mainstream PHP HTTP clients:

One of the interesting bits of research that I've done is benchmarking various mainstream PHP HTTP clients. Of course, we all know that there are lies, damned lies, statistics, and benchmarks, so take these with a grain of salt.

He ran them on his Sony Viao on Ubuntu with a stock PHP5 package. The tested packages were the pecl_http extension, the streams http wrapper, curl integration into PHP 5, PEAR::HTTP Client class and the Zend_Http_Client component. He includes the code he used for both a basic request and for something slightly more complex (posting form data). He used the XDebug and KCachegrind combination to produce the results.

0 comments voice your opinion now!
benchmark http client pecl pear zendframework streams curl


Davey Shafik's Blog:
PHP Streams Book (Coming soon!)
April 25, 2008 @ 12:04:09

We can expect big things from Davey Shafik in the coming months - he's been working on a book for php|architect about one of the more powerful bits of functionality in PHP - streams.

For about 6 months now, I've been itching to write a book on the PHP Streams Layer - one of my favorite features of PHP; and also one of the least known considering it's powerful abilities.

He describes his goal simply as this: to create the definitive resource for working with the streams later in PHP. It should be out sometime in the third quarter of 2008, so keep your eye out for it then.

0 comments voice your opinion now!
streams layer book phparchitect publish definitive guide



Community Events





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


interview laravel project list introduction library threedevsandamaybe wordpress code podcast configure bugfix community release series api framework language developer application

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