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

Przemek Sobstel:
Preventing the Dogpile Effect
August 11, 2014 @ 11:47:28

Przemek Sobstel has a recent post investigating an interesting theory in caching of any kind of application, not just PHP ones. He looks at the dogpile effect: when a cache expires and the database or host cannot catch up with so many non-cached requests coming in.

Implementing caching in web apps seems to be simple. You check if value is cached. If it is, you fetch cached value from cache and serve it. If it's not, you generate new value and store in cache for future requests. Simple like that. However, what if value expires and then you get hundreds of requests? It cannot be served from cache anymore, so your databases are hit with numerous processes trying to re-generate the value. And the more requests databases receive, the slower and less responsive they get. Load spikes. Until eventually they likely go down.

He recommends using something called a "semaphore lock" to help prevent this kind of issue from happening. This lock prevents the removal of any stale content until after one process has finished refreshing the requested data. Only once the lock is released are the other processes allows to serve the fresh data. He includes some PHP pseudo-code that illustrates the point: trying to fetch the content, checking for the lock and releasing it when the single process is done with the refresh. He includes a link to a full implementation as well. He's also written up a full library, Metaphore, that integrates this into a full caching system.

0 comments voice your opinion now!
dogpile effect theory cache tutorial metaphore semaphore

Link: http://www.sobstel.org/blog/preventing-dogpile-effect/

Nikita Popov's Blog:
The true power of regular expressions
June 15, 2012 @ 08:42:57

Nikita Popov has a new (language agnostic) post to his blog today about one of the most powerful things you can use in your development - something that a lot of developers don't understand the true power of - regular expressions.

As someone who frequents the PHP tag on StackOverflow I pretty often see questions about how to parse some particular aspect of HTML using regular expressions. A common reply to such a question is: "You cannot parse HTML with regular expressions, because HTML isn't regular. Use an XML parser instead." This statement - in the context of the question - is somewhere between very misleading and outright wrong. What I'll try to demonstrate in this article is how powerful modern regular expressions really are.

He starts with the basics, defining the "regular" part of "regular expression" (hint: it has to do with predictability) and the grammar of the expressions. He talks about the Chomsky hierarchy and how it relates to the "regular" as well as a more complex mapping of expression to language rules. He talks about matching context-free and context-sensitive languages and unrestricted grammars as well.

0 comments voice your opinion now!
power regular expression define theory context


php|architect:
Programming you're doing it wrong
March 11, 2010 @ 11:06:42

In an opinion piece posted to the php|architect site Marco Tabini suggests that we (as developers) are doing it wrong as we move further and further away from the pragmatic side of programming into the abstract.

No matter how advanced the techniques that we use, there is always something that we could be doing better. [...] Which one is right? The real problem is that the answer to that question is, "yes." That's because it lacks a specific context in which it can be inserted.

He suggests that, in our quest to figure out what the perfect case for any situation, we stop focusing on the practicality of writing applications to accomplish goals. Sometimes it's not about getting the right theory behind the code - sometimes it's just doing it.

0 comments voice your opinion now!
programming opinion theory practical focus


Jacob Santos' Blog:
PHP Opcode Series
March 15, 2007 @ 15:24:00

Jacob Santos has started a series of posts to his blog that focuses on the use of the opcode cache and language features in your applications.

The posts will be researched and go through multiple drafts for professionalism before posting. In this hope, it will strive to enable discussion that isn't flaming and collective of the topic at hand. For as much as I can achieve at my level of writing skill and researching the topic at hand.

He he goes through the purpose of the posts, the areas he's going to focus on, some about the theory that will be used, and the implementation and documentation he'll provide through the series.

0 comments voice your opinion now!
opcode series post purpose focus theory implementation documentation opcode series post purpose focus theory implementation documentation


Lukas Smith's Blog:
Its like everybody sees the wall coming...
October 20, 2006 @ 07:38:00

Despite the release candidates for PHP 5.2.0 marching on, Lukas Smith still has some misgivings about some of the functionality being introduced in the release - specifically about the fatal errors that are going to break a lot of (working) object oriented functionality.

Anyways I just posted the following email to internals in a list attempt to get some of the people with php-dev karma to lift their finger.

In the message, he notes the change he's looking for and a suggestion to get it included before RC6 of the series gets released (which has been released as of this post already).

1 comment voice your opinion now!
fix fatal error object oriented theory functionality break fix fatal error object oriented theory functionality break


SitePoint PHP Blog:
The Joy of Regular Expressions [1]
September 26, 2006 @ 08:02:45

Sometimes, it's just not enough to sit and try to teach theory about something in programming - it's better to just jump right in and take things as they come. That's what Harry Fuecks thinks, at least in his latest post on the SitePoint PHP Blog - a look at the "Joy of Regular Expressions".

He does go over a bit of the theory and why they are so invaluable, but it's a short section before he gets to the heart of the article - working with regular expressions for:

  • positive matching
  • matching all instances in a given string
  • finding an exact match
  • matching the start of a string
  • validation of the contents of a string
  • checking the length of a string
There's simple examples included for each of the items to help you get an idea of how they'd work.

1 comment voice your opinion now!
regular expression tutorial theory matching length contents regular expression tutorial theory matching length contents


Scott Johnson's Blog:
Podcast PHP Theory 1
August 08, 2006 @ 12:22:35

Scott Johnson has created and posted another in his podcast series today, this time, he looks not at the development side of PHP - the actual code - but at the theory behind its development and best practices.

At the request of a listener to past podcasts, Scott created this one to share some of his experiences and findings along the path of his develoopment. Some of the items covered in the podcast include:

  • package and library management
  • naming conventions
  • the seperation of UI and business logic
  • code distribution
  • using test harnesses

You can download the MP3 of the podcast directly from here.

1 comment voice your opinion now!
theory development best practices package library naming logic theory development best practices package library naming logic


Jacob Santos' Blog:
PHPc Compiler Theory and Ranting
July 31, 2006 @ 06:31:11

Jacob Santos is back again today with this new blog post - his look at the world of PHP compilers and some of his theories (and rants) on the subject.

I know very little of compiler and interpreter theory and have never (yet) created a working implementation of a compiler or interpreter. What you're about to read or (most likely) skip over is a Head-in-Ass post and feel free to flame me on parts where I'm wrong, which will be most places. Do realize that this is one end user's opinion of the matter and any perceived insult upon any author(s) is not intended and please do not take it as such.

Jacob talks about run-time classes, class optimization, what he "really wants" out of a compiler, namespace functionality, a "phpc" extension, and his opinions on the Zend Engine, other web technologies, and the future of PHP.

0 comments voice your opinion now!
compiler theory ranting run-time namespace phpc compiler theory ranting run-time namespace phpc



Community Events





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


interview development framework tips community conference series developer release list code zendserver symfony laravel introduction deployment podcast language bugfix api

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