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

Sergey Zhuk:
Managing ReactPHP Promises
Jan 18, 2018 @ 16:50:01

In a new post to his site Sergey Zhuk has a tutorial showing you how to manage promises in ReactPHP. Since promises are fired asynchronously they can be difficult to manage and use their output across the application.

Asynchronous application is always a composition of independently executing things. In concurrency, we are dealing with a lot of different things at once. [...] So, to make concurrency work you have to create a communication between these independent parts to coordinate them. And here come promises. They are the basic unit of concurrency in an asynchronous application. They are the blood of the asynchronous application and move the results between different tasks across the code.

He then covers a few different situations and offers advice on how to more correctly handle them:

  • I don’t know exactly what the resolver will give me
  • I want to reject a promise but without throwing an exception
  • I want to run multiple tasks and when they all finish do something else
  • I have some pending tasks and want to continue once I receive the first feedback
  • I have some pending tasks and want to continue once the first one is completed
  • I have some pending tasks and want to continue once a certain number of tasks will be completed

Code is provided for each of the situations giving you an easy, ready to use example for your application. Most require only a few lines to get the job done and can be very useful in the right circumstances.

tagged: reactphp manage promises situation code example tutorial

Link: http://sergeyzhuk.me/2018/01/16/reactphp-managing-promises/

Simas Toleikis' Blog:
PHP data caching techniques
Dec 13, 2010 @ 14:45:10

Simas Toleikis has posted some caching techniques he's come up with to handle a few different situations including simple file-level caching and working with memcached.

Caching intermediate data is the most primitive and yet the most rewarding optimization technique where you don’t need to fiddle with any complex algorithms or premature optimizations. If you are into PHP you should be aware of all the best practices and the right tools for this job to make your websites fly.

He covers a few different, though common, situations you may come across in your application where caching could be very helpful:

  • Static scope variables
  • APC shared memory functions
  • Memcached for large distributed caches
  • In-memory database tables
  • Simple file-level caches
tagged: caching technique situation apc memcache file memory

Link:

Elizabeth Smith's Blog:
Fun with compiling - Gtk+, PHP-Gtk2, and MSVC
Dec 19, 2006 @ 20:34:00

Elizabeth Smith has a new post to her blog today covering some of the fun she's been having with compiling things like Gtk+ and PHP-Gtk2.

So I've been using microsoft visual studio (actually it's Visual C++ Express, but uses the same stuff behind the scenes) to work on getting things compiled on windows. PHP-Gtk2 allows for some nifty extensions, well at least on linux. So I've been working to get versions of libglade, scintilla, gtksourceview and mozembed working on windows. It's a long, slow process. Here's the deal so far.

She talks about her current situation (what's compiling and what's not) and the software that she's trying to get up and running. She also mentions a problem she's been having with an error message talking about "unresolved external symbols" she'll need to track down (or get some help on - anyone out there seen it?)

tagged: compiling phpgtk gtk msvc situation unresolved external symbol compiling phpgtk gtk msvc situation unresolved external symbol

Link:

Elizabeth Smith's Blog:
Fun with compiling - Gtk+, PHP-Gtk2, and MSVC
Dec 19, 2006 @ 20:34:00

Elizabeth Smith has a new post to her blog today covering some of the fun she's been having with compiling things like Gtk+ and PHP-Gtk2.

So I've been using microsoft visual studio (actually it's Visual C++ Express, but uses the same stuff behind the scenes) to work on getting things compiled on windows. PHP-Gtk2 allows for some nifty extensions, well at least on linux. So I've been working to get versions of libglade, scintilla, gtksourceview and mozembed working on windows. It's a long, slow process. Here's the deal so far.

She talks about her current situation (what's compiling and what's not) and the software that she's trying to get up and running. She also mentions a problem she's been having with an error message talking about "unresolved external symbols" she'll need to track down (or get some help on - anyone out there seen it?)

tagged: compiling phpgtk gtk msvc situation unresolved external symbol compiling phpgtk gtk msvc situation unresolved external symbol

Link:

SitePoint PHP Blog:
The Joy of Regular Expressions [4]
Oct 30, 2006 @ 21:34:00

Harry Fuecks brings the next part of his "Joy of Regular Expressions" series to the SitePoint PHP Blog today with part four, building on the previous how-tos: part one, part two, and part three.

He looks at a few different topics this time - date checking, making dates more user-friendly, exploding with patterns, and capturing split delimiters. Just like in the previous articles in the series, he explains in what kind of situation the expression would be used and the sample code showing how to use it (oh, and the output too).

tagged: regular expresssion joy tutorial example situation regular expresssion joy tutorial example situation

Link:

SitePoint PHP Blog:
The Joy of Regular Expressions [4]
Oct 30, 2006 @ 21:34:00

Harry Fuecks brings the next part of his "Joy of Regular Expressions" series to the SitePoint PHP Blog today with part four, building on the previous how-tos: part one, part two, and part three.

He looks at a few different topics this time - date checking, making dates more user-friendly, exploding with patterns, and capturing split delimiters. Just like in the previous articles in the series, he explains in what kind of situation the expression would be used and the sample code showing how to use it (oh, and the output too).

tagged: regular expresssion joy tutorial example situation regular expresssion joy tutorial example situation

Link:

Ivo Jansch's Blog:
Defensive Programming
Jan 27, 2006 @ 13:01:48

In his latest blog post today, Ivo Jansch takes a look a t a situation where a little "defensive programming" would have helped.

A few weeks ago, we had a major problem with software we'd written for a client. It was software for sending mailings to the client's customers. Suddenly there were many reports of clients receiving multiple mailings instead of just one.

The problem appeared to be in our test code. The software had a 'test' mode for testing the mailing by sending it only to the author and a small test team. It appeared that for some reason, all test mails were being mailed to the customers as well.

This problem would not have appeared if we had applied what I would like to call 'defensive programming'.

He shows code examples from this situation, pointing out where the issue lies - a bad check in an if() statement.

tagged: defensive programming error situation defensive programming error situation

Link:

Ivo Jansch's Blog:
Defensive Programming
Jan 27, 2006 @ 13:01:48

In his latest blog post today, Ivo Jansch takes a look a t a situation where a little "defensive programming" would have helped.

A few weeks ago, we had a major problem with software we'd written for a client. It was software for sending mailings to the client's customers. Suddenly there were many reports of clients receiving multiple mailings instead of just one.

The problem appeared to be in our test code. The software had a 'test' mode for testing the mailing by sending it only to the author and a small test team. It appeared that for some reason, all test mails were being mailed to the customers as well.

This problem would not have appeared if we had applied what I would like to call 'defensive programming'.

He shows code examples from this situation, pointing out where the issue lies - a bad check in an if() statement.

tagged: defensive programming error situation defensive programming error situation

Link:

Paul Jones' Blog:
Fluent Interfaces Require Fluent Situations
Dec 30, 2005 @ 12:51:41

On Paul Jones' blog today, he talks about something that's coming up more and more (and has especially been mentioned in PHp with all of the new frameworks popping up) - fluent interfaces.

My friend and coworker Mike Naberezny wrote recently of fluent interfaces (a.k.a. object chaining). The idea is that the fluent interface makes it very easy to read the resulting code in a way that flows naturally. This is cool, but I want to add a caveat to his examples.

I think, for a fluent interface to be effective, you need situations where you actually have all that information at one time so that you can chain the methods in a fluid way.

Paul continues, talking about that "something more" that might be needed to get this kind of thing working in PHP - the need to have all of the information that's going to be chained at once.

tagged: fluent interface fluent situation all data at once fluent interface fluent situation all data at once

Link:

Paul Jones' Blog:
Fluent Interfaces Require Fluent Situations
Dec 30, 2005 @ 12:51:41

On Paul Jones' blog today, he talks about something that's coming up more and more (and has especially been mentioned in PHp with all of the new frameworks popping up) - fluent interfaces.

My friend and coworker Mike Naberezny wrote recently of fluent interfaces (a.k.a. object chaining). The idea is that the fluent interface makes it very easy to read the resulting code in a way that flows naturally. This is cool, but I want to add a caveat to his examples.

I think, for a fluent interface to be effective, you need situations where you actually have all that information at one time so that you can chain the methods in a fluid way.

Paul continues, talking about that "something more" that might be needed to get this kind of thing working in PHP - the need to have all of the information that's going to be chained at once.

tagged: fluent interface fluent situation all data at once fluent interface fluent situation all data at once

Link:


Trending Topics: