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

SitePoint PHP Blog:
HHVM and Hack - Can We Expect Them to Replace PHP?
February 13, 2014 @ 09:29:39

The SitePoint PHP blog has a new post today that asks can we expect HACK and HHVM to replace PHP as an evolution of the PHP language and interpreter.

HHVM is intended to achieve both parity with the Zend Engine features and best possible performances. Facebook claims a 3x to 10x speed boost and 1/2 memory footprint by switching from PHP+APC to HHVM. Of course this is really application dependent (10x being for the FB code base). [...] Instead this article will focus on HACK which is an evolution of the PHP language designed to be safer, to enable better performance and to improve developer efficiency.

He starts off by helping you get an instance of HHVM up and running (via Vagrant) and create a simple HACK script. From there he gets into some of the more advanced HACK features like constructor argument promotion and collections. The talks some about typing, type hinting and the use of generics as well.

0 comments voice your opinion now!
hack hhvm facebook introduction tutorial type collection constructor

Link: http://www.sitepoint.com/hhvm-hack-part-1/

SitePoint PHP Blog:
Collection Classes in PHP
September 30, 2013 @ 12:21:30

On the SitePoint PHP blog a new tutorial introduces you to collection classes in PHP, replacing the more basic array with something with a bit more power.

Applications frequently have objects that contain a group of other objects, and this is a great place to make use of collections. [...] A Collection class is an OOP replacement for the traditional array data structure. Much like an array, a collection contains member elements, although these tend to be objects rather than simpler types such as strings and integers.

He mentions some of the common problems with arrays (and the data they contain) and points out that the structure a "Collection" class wraps around it can help keep things sane. He includes an example of a basic collection class that adds/gets/deletes items from an internal (private) array. He fleshes out this class with code inside those methods and a few others: keys, length and keyExists.

0 comments voice your opinion now!
collection class oop array tutorial

Link: http://www.sitepoint.com/collection-classes-in-php/

Joshua Thijssen:
PHP's Resources and garbage collection
July 12, 2013 @ 10:54:34

Joshua Thijssen has put together a new post with details about garbage collection in PHP and a "nice bug/feature/whatsmathing" he found related to it and its performance.

I was playing around with writing a daemon and if you have any experience writing daemons (in any language), there are a few rules you have to live by. For instance, setting your effective uid and gid to a non-privileged user (in case you needed to do some privileged initialization, like opening a socket on a tcp port < 1024), setting the process as a group leader with posix_setsid(), and redirecting stdio file descriptions. And here something went wrong which took a while to find and fix..

He was creating a daemon and the script would just exit without a warning and not continue running. He narrowed down the issue to a few lines (with fopen and fclose) and went to debug it with strace to really see what was happening. He found some unexpected calls in the stack trace and, after some more digging, finally figured out it was a problem of both scope and cleanup that was resulting in the extra calls.

0 comments voice your opinion now!
garbage collection resource stdin stdout stderr bug

Link: http://www.adayinthelifeof.nl/2013/07/10/phps-resources-and-garbage-collection

PHPMaster.com:
Better Understanding PHP's Garbage Collection
July 12, 2012 @ 11:10:22

If you've been working with PHP for any length of time, you probably have wondered what happens to everything you've created when your script's execution ends. Well, in this new post from PHPMaster.com PHP's garbage handling functionality.

It's interesting how just a few years can make a difference in the names that are given to things. If this were to come up today, it would probably be called PHP Recycling Options, because rather than picking things up and throwing them into a landfill where they'll never be seen again, we are really talking about grabbing things whose use has passed and setting them up to be useful again. But, recycling wasn't le petit Cherie of society back when the idea was developed and so this task was given the vulgar name of 'Garbage Collection'. What can we do but follow what history and common usage have given us?

They talk about a few different kinds of data that the garbage collection system cleans up including the program-generated information and the three tiered system the languages for cleanup:

  • First Level - End of Scope
  • Second Level - Reference Counting
  • Third Level - Formal Garbage Collection
0 comments voice your opinion now!
garbage collection tutorial introduction


PHPMaster.com:
An Intro to Virtual Proxies, Part 2
April 26, 2012 @ 09:24:23

Following up on his previous article, Alejandro Gervasio has a new post to PHPMaster.com with the second part of his series on using virtual proxies in PHP.

Resting on the foundation of Polymorphism (dynamic Polymorphism, not the ad-hoc one often achieved through plain method overriding), Virtual Proxies are a simple yet solid concept which allows you to defer the construction/loading of expensive object graphs without having to modify client code.

He shows how to create a collection of domain objects that use proxies to populate their data. He includes the code for creating a "Post" interface/object as well as a Comment interface/object. These are put into a "CommentCollection" and, when it's accessed, pull the item in the collection out, only populating the data on demand.

0 comments voice your opinion now!
virtual proxies introduction series collection domain object


Chris Hartjes' Blog:
PHPUnit Aborted Fix
January 19, 2012 @ 11:16:53

Chris Hartjes ran into an issue with hit unit tests where PHPUnit was throwing an "aborted" error no matter what tests were run. Thankfully, in this new post, he shares a solution.

That was a pretty annoying bug. I never did find out what the problem was as I moved onto other problems and chalked that error up to some undiagnosed weirdness on that particular server. From time to time I would get asked on Twitter if I had ever solved the problem. My answer was always "no, and if you do solve it please let met know how you fixed it." Today, my friends, was the day.

Based on a response from Demian Katz, he was able to get around the issue with flag set on the PHPUnit command line - "-dzend.enable_gc=0". Apparently the issue has to do with garbage collection and has been a known issue since the beginning of 2011.

0 comments voice your opinion now!
phpunit aborted unittest fix garbage collection bug


Ed Finkler's Blog:
Building a Tumblelog with Gimme Bar and PHP
November 07, 2011 @ 10:47:50

Ed Finkler has a new post today showing how he's created a tumbleblog using the Gimmie Bar API and backend as a source for the posts. For the curious, the code for his simple blog can be found here.

One of the coolest things about working on Gimme Bar has been the opportunity to build a platform. While most folks interact with our service via the web site, the site is just one application built on top of the Gimme Bar content collection and curation system. Our web site interacts with the system via our HTTP API, which is open to everyone, not just our internal team. That means that anyone can build applications on top of our platform to suit their own needs or interests.

This simple blog (demo here grabs items from his Gimmie Bar feed and posts them. He includes complete installation instructions and a brief overview of how the parts work together.

0 comments voice your opinion now!
tumbleblog blog gimmiebar api tutorial example content collection


Derick Rethans' Blog:
Collecting Garbage Performance Considerations
September 13, 2010 @ 11:22:42

Derick Rethans has posted the third part of his series looking at the garbage collection handling in PHP (the first two parts are here: one, two). In this last part of the series, he'll look at some of the possible performance impacts the garbage collection functionality can have in your applications.

In the previous two parts of this column we have explored PHP's take on circular referenced variables and a mechanism that allows to clean up this particular problem with reference counted variable tracking. Of course, the implementation of the garbage collection mechanism in PHP 5.3 has some performance impacts. In this third and last part of the column I will cover the performance implications of the addition of this garbage collection mechanism.

He looks at the two possible places that the collection could have an impact - memory usage and run-time delays when the garbage collection routine is fired off and does its job. As before, each of the topics is accompanied by bits of code and a few graphs showing the differences between handling in PHP 5.2 and PHP 5.3 as well as a handy way to get a bit more information out of PHP (using the GC_BENCH CFLAG when compiling). ,/p>

0 comments voice your opinion now!
garbage collection performance memory usage runtime delay


Derick Rethans' Blog:
Collecting Garbage Cleaning Up
September 07, 2010 @ 09:56:25

Derick Rethans has continued his series on garbage collection in the PHP internals with this second post of the series with a special look at circular references. You can find the first part here.

In this second part of the three part column on the new garbage collecting mechanism in PHP 5.3, we'll dive into a solution to the problem with circular references. If we look quickly back, we found that by using code like the [first example], an in-request memory leak is created.

He goes on to briefly describe the synchronous algorithm (including a few more helpful graphs to show the flow) and how that has worked its way into the PHP garbage collection methods. He also points out that this collection can be turned off and on via the gc_enable and gc_disable functions. Keep an eye out for the next part of the series where he gets into more detail on how this is all integrated into PHP.

0 comments voice your opinion now!
garabage collection article phparchitect circular references


Derick Rethans' Blog:
Collecting Garbage PHP's take on variables
August 31, 2010 @ 10:49:11

Derick Rethans is republishing an article series he wrote (originally for php|architect) about the garbage collection that is included with the PHP 5.3 releases. He kicks off the series with this first post introducing internal variable handling.

Before we start with the intricate details of PHP's new GC engine I will explain why it is actually needed. This, combined with an introduction how PHP deals with variables in general is explained in this first part of the column. The second part will cover the solution and some notes on the GC mechanism itself, and the third part covers some implications of the GC mechanism, as well as some benchmarks. But now first on to the introduction.

He introduces the concept of a "zval" - the container PHP uses internally to handle variables (along with its "is_ref" and "refcount" to tell the interpreter if it's a reference or not). He also shows how these relate to the variables you set in your applications as well as a mention of the xdebug_debug_zval function of XDebug to show how it's handled behind the scenes. He also shows how references are handled with accompanying images to show the flow. If you'd like more information on variable handling, Derick points to this article for more detail.

0 comments voice your opinion now!
garbage collection variable introduction zval reference xdebug



Community Events





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


series symfony introduction update library security package composer community framework opinion language interview mvc podcast release voicesoftheelephpant laravel tool version

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