"Mastering the SPL Library"? book review

"Mastering the SPL Library" book review

This is a review of the book "Mastering SPL Library" by Joshua Thijssen. I'd like to share my opinion regarding this book and if it worths reading.

I decided to read something about the SPL after I failed with several questions about it during the Symfony certification. SPL was created a while ago. Nevertheless, good documentation with examples and descriptive explanations never was written. After a short search, I discovered this book. Even though the book was published in 2013 and can't be considered as completely up-to-date, it has a lot of useful information regarding the Standard Library.

SPL contains Iterators, Datastructures, some interfaces, a set of exceptions and other functionality like autoloading and file handling.

The Iterator is quite a useful tool to have a clean and readable traversal and allows to move a business logic out of a loop; in my opinion, this piece of functionality could be used widely. The downside is that it wasn't rewritten in PHP 7 so it's slow compared to generators.

A data structure standing behind the PHP array is called a "hash table". It has its downsides, and in some cases, it is not that effective as other data structures. SPL has plenty of them https://www.php.net/manual/en/spl.datastructures.php , but you need to consider that these data structures are implemented not in the best way. There is an extension "ds" that is more effective. Here is an article with some benchmarking about this extension https://medium.com/@rtheunissen/efficient-data-structures-for-php-7-9dda7af674cd

SPL file handling has an object-oriented interface to work with files. This approach could substitute PHP functions like "fopen" in your codebase.

The book "Mastering SPL Library" is an excellent way to learn about the SPL with a rich set of examples. It's not very popular, a bit outdated, but anyway I found it quite useful. I would recommend this book to advanced PHP developers who want to deepen their knowledge of PHP.

要查看或添加评论,请登录

Anton Chernikov的更多文章

  • Review on "Essential Algorithms"

    Review on "Essential Algorithms"

    This is a review article on a book "Essential Algorithms" written by Rod Stephens. I'd like to share my thoughts on it.

  • Grokking Algorithms

    Grokking Algorithms

    There are a lot of helpful IT books worth reading and there a lot of books that are not as good. We are definitely…

社区洞察

其他会员也浏览了