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

BitExpert Blog:
Think About It: PHPExcel Performance Tweaks (Part 1)
Jul 07, 2015 @ 15:34:21

Florian Horn has posted the first part of a series of performance tweaks for using PHPExcel to work with Excel spreadsheets and CSV data.

A few weeks back I covered a small article about a CSV-Tool optimized for memory usage and additionally tweaking performance. Our performance optimization sprint contained the improvement of read file data, processing and persist it. While the file data is relatively small referred to the file size, the amount of data sets can vary between 5.000 and more then 40.000 entities on an average, but may be a lot more in some cases.

This article is the first of a three-part series and describes how we tweaked PHPExcel to run faster while reading Excel and CSV files.

In this first part of the series he goes through three different tips to improve some of the basic performance:

  • Cache Cell Index in Memory
  • Iterators and GC Optimization
  • Use Custom Read Filters

You can find out more about the PHPExcel library on the project's main page.

tagged: phpexcel performance tweak series part1 cache iterators filter

Link: https://blog.bitexpert.de/blog/think-about-it-phpexcel-performance-tweaks-part-1/

Anthony Ferrara:
Iterators - Programming With Anthony
Jan 17, 2013 @ 16:38:45

Anthony Ferrara is back again with another installment in his "Programming with Anthony" video series. In this new episode he takes a loot at iterators in PHP and how they can be used effectively.

Today's Programming With Anthony video focuses on the concept of Iterators. We'll look at the abstraction that they represent, how they can be used and some of the benefits of using them. When used correctly, Iterators can lead to very efficient, flexible and clean code.

You can also watch the video directly on YouTube and check out the rest of the series in his playlist. Other topics include dependency injection, boolean logic and prepared statements.

tagged: video tutorial programming iterators series

Link:

PHPMaster.com:
Using SPL Iterators, Part 2
May 22, 2012 @ 13:23:17

On PHPMaster.com today they've posted the second part of the series covering the Iterators that come with PHP as a part of the SPL.

In part one of this series I introduced you to some of the SPL Iterators and how to use them. There may be times however when the provided iterators are insufficient for your needs and you’ll want to roll your own custom iterator. Luckily, SPL provides interfaces that will allow you to do just that. For an object to be traversable in a foreach loop, PHP requires that it be an instance of Traversable. You cannot however implement this interface directly (though you can use it in instaceof checks); instead you’ll need to implement either SPL’s Iterator or IteratorAggregate interfaces.

He shows you how to implement these two interfaces in your own custom classes, looping through a set of books for the Iterator example and a "getIterator" method that creates an ArrayIterator when executed. The results of both are used in foreach loops showing how they can be used just like any other iteratable variables.

tagged: spl iterators tutorial array iterator iteratoraggregate foreach

Link:

PHPMaster.com:
Using SPL Iterators, Part 1
May 15, 2012 @ 17:26:59

On PHPMaster.com today there's a new tutorial posted, the first part of a series, looking at the use of the Standard PHP Library (SPL) in PHP. In this first part of the series, Stefan Froelich looks specifically at two of the more common uses for iterators - working with arrays and directories.

When I first came across the term iteration and saw the overwhelming list of classes related to it in the SPL, I was taken aback. It seemed maybe iteration was too complex for me to grasp. I soon realized it was just a fancy word for something we programmers do all the time. [...] In the first part of this two-part series I’ll introduce you to iteration and how you can take advantage of some of the built-in classes from the Standard PHP Library (SPL).

Included in the tutorial is example code showing how to use the ArrayIterator to work with an array and the DirectoryIterator to process the contents of a directory. He also briefly touches on a few other iterators like "FileExtensionFilter", "RecursiveDirectoryIterator" and "RecursiveArrayIterator".

tagged: spl iterators tutorial array directory file recursive

Link:

PHPImpact Blog:
5 great articles on SPL Iterators
Aug 07, 2008 @ 14:35:03

On the PHP::Impact blog today Federico points out five articles that can help you learn more about the Standard PHP Library, specifically in dealing with iterators.

When PHP 5 was initially released, it included a strong sense of standardization introduced in the core package. This can be a real time saver when common programming issues must be solved through proven, standard solutions. That's precisely the case with iterators, since the SPL package includes many predefined iterating classes that can be used for traversing different data structures, without having to reinvent the wheel over and over again.

The links include this article on phpro.org and this one on Zend's own site.

tagged: spl iterators link resource tutorial php5

Link:

DevShed:
Iterators in the Simplest Sense - Traversing Different Data Structures
Mar 15, 2006 @ 18:50:40

DevShed has posted the second part in their "Iterators in the Simplest Sense" series - this time focusing on traversing different data structures.

Welcome to the second tutorial of the series "Iterators in the simplest sense." Just in case you didn't know, this series introduces Iterators in PHP 4 – PHP 5, explaining their basic concepts, and teaches you how to use them in practical projects, which can be utilized as part of larger PHP applications.

By the end of this tutorial, I hope you'll have an accurate idea of how to use a generic Iterator structure. I will show how it is useful for traversing different data structures by providing specific implementations for each of the abstract methods defined within the base Iterator class.

They look first at extending the code that they had before by making an interator to work with a MySQL connection. They discuss how it will all work prior to coding (plan first, code later) before moving into the actual coding process and creating the class. The iterator, once extended, provides an interface between you and the normal MySQL functions, making it easier to handle the results from your queries (with things like "countAffectedRows" and "seekRow").

tagged: iterators data structures files mysql iterators data structures files mysql

Link:

DevShed:
Iterators in the Simplest Sense - Traversing Different Data Structures
Mar 15, 2006 @ 18:50:40

DevShed has posted the second part in their "Iterators in the Simplest Sense" series - this time focusing on traversing different data structures.

Welcome to the second tutorial of the series "Iterators in the simplest sense." Just in case you didn't know, this series introduces Iterators in PHP 4 – PHP 5, explaining their basic concepts, and teaches you how to use them in practical projects, which can be utilized as part of larger PHP applications.

By the end of this tutorial, I hope you'll have an accurate idea of how to use a generic Iterator structure. I will show how it is useful for traversing different data structures by providing specific implementations for each of the abstract methods defined within the base Iterator class.

They look first at extending the code that they had before by making an interator to work with a MySQL connection. They discuss how it will all work prior to coding (plan first, code later) before moving into the actual coding process and creating the class. The iterator, once extended, provides an interface between you and the normal MySQL functions, making it easier to handle the results from your queries (with things like "countAffectedRows" and "seekRow").

tagged: iterators data structures files mysql iterators data structures files mysql

Link:


Trending Topics: