user887222
user887222

Reputation:

I'm trying to get streams in php

So I've been on the whole researching techniques for better architecture and run time performance and streams have come up, reading through the documentation and a blog post I am now only dimly aware of using streams. My question is how would you explain streams,streamWrappers, and what's the cleanest O-O implementation ?

I currently think that I might be able to use a stream function object that could improve the speed of returning application views, and client request handling. but I don't know how.

anyway... does anyone understand what I'm getting at? I don't think it's neccesisarily trivial.

Upvotes: 1

Views: 95

Answers (2)

user887222
user887222

Reputation:

Streams are simple enough really, being only a resource object that acts like a stream: readable and writable in linear fashion, so I/we are dealing with streams if only obliquely every time we code something that specifies what and how we serve in response to requests. While there's a lot more to it than that there's a pear extension named pecl_http which really simplifies working http.

Upvotes: 0

Evert
Evert

Reputation: 99841

Unless your 'views' are huge, you will see very little benefit from streams.

So there's two possibilities here, from my perspective:

  1. You think you could make things even faster than they are
  2. You actually have a performance issue, and think you can make things faster with streams.

If you are in category #1, don't look in this direction. Unless you are dealing with bigger files, this will be relevant.

If you are in category #2, then there's is an extremely small chance that your bottleneck is in your view. Generally with PHP applications this is one of the fastest parts of your application.

Instead you should install xdebug, start profiling and analyze your code with Webgrind/Valgrind/KCachegrind/WinCacheGrind. This will give you a ton of information and tell you exactly where your problem is.

Upvotes: 4

Related Questions