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

Matthew Weier O'Phinney:
PSR-7 is in Voting Stage!
March 20, 2015 @ 11:19:03

As Matthew Weier O'Phinney has posted, the PSR-7 PHP-FIG proposal is in the voting stages. The PSR-7 standard defines a unified interface for working with HTTP requests and responses.

As of a short bit ago, PSR-7 (meta) - HTTP Message Interfaces - is now in the voting phase! If you are a voting member of PHP-FIG, I urge you to read the specification and meta document now, and cast your vote accordingly.

I have written previously on the need for HTTP message abstractions, and also detailed how PSR-7 works. Those posts are still valid (I've kept the latter updated with all changes!). Since the review period, my sponsors and I have been looking over feedback and comments to see if any changes were needed. Fortunately, we've not found any substantive changes were really necessary; we have, however, made a few clarifications.

He clarifies some things around:

  • why base path concerns are not represented in the ServerRequestInterface or UriInterface
  • a note that UriInterface::getPath() MUST return the string "/" if the path is empty
  • that UriInterface implementations MUST percent-encode reserved characters in paths and query strings, per RFC 3986
  • why StreamableInterface is mutable, and provided guidelines to implementors and consumers regarding how and when to use writable streams
  • the addition of several sections to the meta documentation detailing solutions to common stream-based concerns

He also gets into a bit more detail about streams, base paths and some of the overall outcomes if the PSR-7 proposal passes (which it looks like it will so far).

If you adopt PSR-7, will you need to change your code? Almost certainly. The goal of PHP-FIG is to improve interoperability between projects, and PSRs typically attempt this via codification of what member projects are already doing.
0 comments voice your opinion now!
psr7 voting stage clarification basepath stream outcome

Link: https://mwop.net/blog/2015-03-19-psr-7-ready-for-vote.html

Edd Mann:
Implementing Streams in PHP
January 16, 2015 @ 10:09:22

Edd Mann has a new post today looking at implementing streams in your PHP applications. In this case we're not talking about the streams built into PHP but the concept of a source of information that only produces the next item when requested (aka "lazy loading").

Typically, when we think about a list of elements we assume there is both a start and finite end. In this example the list has been precomputed and stored for subsequent traversal and transformation. If instead, we replaced the finite ending with a promise to return the next element in the sequence, we would have the architecture to provide infinite lists. Not only would these lists be capable of generating infinite elements, but they would also be lazy, only producing the next element in the sequence when absolutely required. This concept is called a Stream, commonly also referred to as a lazy list, and is a foundational concept in languages such as Haskell.

He talks about how streams of data should be interacted with differently than a finite list of data and the promises they're based on to provide the right data. He shows two different approaches to implementing a an object to stream data from - a class-based method and one that uses generators. Sample code is provided for each with the generator approach being a bit shorter as they're designed to lazy load items as requested.

0 comments voice your opinion now!
stream data lazyload generator class iterator tutorial

Link: http://eddmann.com/posts/implementing-streams-in-php/

Laravel Podcast:
Episode 19 - Join the Live Stream
November 05, 2014 @ 09:43:08

The Laravel.io podcast has made an announcement that today (Wednesday, Oct 5th) they will be doing a live stream of episode #19 at 2pm EST.

Tomorrow at 2:00 PM EST the latest Laravel.io Podcast will be aired live on Google Hangouts. Currently no topics are listed but you will be able to ask questions live on the air.

If you'd like to join in, head over to this page around 2pm and join in on the conversation. If you're interested in other back episodes of the show and want to listen, check out the podcast page and subscribe to their feed.

0 comments voice your opinion now!
laravelio podcast ep19 live google hangout stream conversation

Link: https://plus.google.com/events/clqi0dcpb07vs0qgiorjvd2fdis

Hannes Magnusson:
Query logging and profiling in MongoDB
September 18, 2013 @ 10:25:49

in a previous post Hannes Magnusson introduced the new stream handling notification feature in the MongoDB PHP extension. In his most recent post he elaborates on a subject mentioned in the previous post - query logging and profiling.

In my previous blog post I mentioned that the 1.5.0 release of the MongoDB driver for PHP has improved notification support using the PHP Notification API, and showed off a fairly useless (but fun) progress bar. Now its time for a little bit more practical examples using this system: Query logging and profiling.

He talks about some of the features in his pull request, including the new constants added to help make working with the logging on streams easier. He includes some sample code that handles the logging via an "update" callback function, parsing the log message type and save the related data to a class variable. An instance of this class is then assigned to the "notification" stream and passed in as an additional option when creating the MongoClient connection. He includes an example of querying a basic collection and how to extract the request information from the logging object instance.

0 comments voice your opinion now!
mongodb stream context tutorial log query profile notification api

Link: http://bjori.blogspot.com/2013/09/query-logging-and-profiling-in-mongodb.html

DZone.com:
External processes and PHP
February 14, 2013 @ 11:29:04

In a new tutorial over on DZone.com Giorgio Sironi talks about handling external processes in PHP and how to work with streams.

I've come to known a bit about spawning and monitoring new processes from PHP code, while working at Onebip and trying to contribute to Paratest. Here's what you need to know if you think exec() or executing everything in a single .php script is always enough.

He starts with a look at the differences between using things like exec and streams for handling the spawning of other processes. He shows how you have more control when you go with the streams option and process handling with the "proc_*" methods. He also touches on some other things to think about like stream blocking, sleeping and dealing with multiple execution streams (and switching between them).

0 comments voice your opinion now!
external process tutorial stream handling


Community News:
ZendCon Keynotes Live Stream
October 23, 2012 @ 08:27:35

If you weren't able to make it to this year's ZendCon conference (happening right now in Santa Clara, CA) you can at least get a little taste of it though their live video stream of the keynotes.

There's five sessions they'll be sharing via the stream starting today and running through the 25th:

  • Opening Keynote - Andi Gutmans (Zend)
  • Open Source Cloud Technologies - Jimmy Guerrero (Red Hat, Inc.), Adrian Otto (Rackspace) and Peder Ulander (Citrix Systems)
  • The Media Industry and Moving to PHP - Raghu Bala (Source Interlink), Brent Pearson (UBM Technology)
  • PHP in the Cloud: Choice, Scale, Code, Simplify - Simone Brunozz (Amazon Web Services)
  • Zend Framework 2 - Practical Experience from the Trenches - Matthew Weier O`Phinney (Zend Technologies), Shawn Stratton (Discovery Communications, Inc.), Evan Coury (SouthwestMedical.com) and Mike Willbanks (CaringBridge)

The Opening Keynote starts at 8:30am PDT, so keep your eyes here for that broadcast.

0 comments voice your opinion now!
zendcon12 live stream keynote broadcast conference


Paul Jones' Blog:
When Possible, Use File *Resources* Instead Of File *Names*
July 04, 2012 @ 14:10:49

In this new post to his blog Paul Jones makes a suggestion when you're working with files or external connections in your PHP applications - pass the resource, not the file/path name for more flexibility.

In testing the Aura.Http package, I have realized that it's much more flexible, testing wise, to pass around file resources (a.k.a. handles, pointers, or streams) than it is to pass around file names. When you do that, you can use a php://memory stream instead of attempting to touch the file system.

He shows how using this method can make it easier to test with a simple bit of refactoring by passing in the "php://memory" stream rather than the actual file reference. The comment (from Chris Hartjes) also suggests an alternative tool for working with tests that need the file system, vfsStream.

0 comments voice your opinion now!
file resource filename opinion unittest phpmemory stream


Joshua Thijssen's Blog:
PHPShout a shoutcast streamer in PHP
March 27, 2012 @ 08:36:55

Joshua Thijssen has a new series of posts to his blog about a new extension he's created for PHP that lets you stream music files to an IceCast server with only PHP.

To continue our journey in pointless, but nevertheless fun things to create, I've created a simple PHP extension that allows you stream music data to an IceCast server in pure PHP. For this I'm using the libshout3 library which can stream both MP3 or OGG/Vorbis data to multiple stream servers (including IceCast, ShoutCast etc). In this blog-post I will try to explain how I've created this extension, and off course, how you can use it.

The series is split up into four parts:

  • Part 1 - download and install (and some behind the scenes)
  • Part 2 - parts of the extension and a first test
  • Part 3 - populating the store, adding getters
  • Part 4 - creating setters and some other random functionality

You can find the source for this extension over on his gihub repository.

0 comments voice your opinion now!
shoutcast stream audio extension tutorial


VG Tech Blog:
Unit Testing with Streams in PHP
December 08, 2011 @ 09:13:28

On the VG Tech blog today there's a new post from André Roaldseth about using PHPUnit to test PHP streams, basing the assertions on the data rather than the functionality itself.

Using the memory/temporary stream provided by php:// stream wrapper you can create a stream with read and write access directly to RAM or to a temporary file [using "php://memory"]. This gives you the possibilty to write unit tests that does not rely on a specific file, resource or stream, but rather on data provided by the test itself.

There's no specific code examples here, but you can refer to the stream wrappers section of the PHP manual for more details on this and other handy built-in streams. Once created, it can then be used just as any other stream resource can. This could be useful to provide mocks in your testing, replacing any other stream-able resource with a "memory" or "temp" placeholder.

0 comments voice your opinion now!
unittest stream memory temp wrapper mock object


DZone.com:
Using a stream wrapper to access CouchDb attachments with PHP
April 28, 2011 @ 10:45:27

On DZone.com today there's a new post from Gonzalo Ayuso about using a stream wrapper to access CouchDb database directly from PHP (via a call to its local file).

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). It's pretty straightforward to create the wrapper. Of course it's only an approach. We can create more functionality to our stram wrapper but at least this example meets my needs.

His wrapper uses a client from his Nov framework to open the stream to the given path and gives read and write methods to work with the data inside the database. Code for the wrapper class is included as well as a bit of example code showing how it can be used with the custom stream protocol. You can find the complete code here.

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



Community Events

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


laravel example install podcast community unittest language introduction interview api laravel5 voicesoftheelephpant extension library xdebug release framework php7 opinion series

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