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

Laravel News:
Review: Refactoring to Collections
Feb 16, 2017 @ 16:45:33

The Laravel News site has posted a book review by Diaa Fares of Adam Wathan's "Refactoring to Collections" book.

“Never write another loop again.” A strong promo sentence used by Adam Wathan to market his Refactoring to Collections book, but does it hold the promise? Well, together we will explore how close that claim is to reality.

If you are a Laravel developer, chances are you’ve heard about the collection pipeline before. While I use it a little in my projects I hadn’t realized the possibilities of this approach until I read Refactoring to Collections. It brought me to another level of thinking about utilizing the power and capabilities of functional programming.

The review goes on to talk about imperative versus declarative programming (with examples) and how the book walks you through "the journey" to move to a collections-driven code structure. The review also points out the amount of concepts to learn in the book and the style/effort that was clearly put into its creation. It also points to this RFC as hope for the native use of "arrow functions" in PHP in the future.

tagged: refactor collections book review adamwathan

Link: https://laravel-news.com/review-refactoring-to-collections

Laravel News Podcast:
Episode #20 - With special guest Adam Wathan
Jun 30, 2016 @ 23:20:24

The Laravel News podcast, as hosted by Eric Barnes has posted their latest episode: Episode #20: With special guest Adam Wathan.

In this week’s Laravel News podcast we have Adam Wathan on to talk about his book Refactoring to Collections and a new package MailThief.

You can listen to this latest episode either through the in-page audio player or by subscribing through iTunes or Google Play. There's also a special discount code included for Adam's "Refactoring with Collections" book if you're interested.

tagged: laravelnews podcast ep20 adamwathan laravel collections mailthief

Link: https://laravel-news.com/2016/06/ln-20-special-guest-adam-wathan/

Full Stack Radio:
Episode #39 - Michael Feathers - First Class Error Handling, Tell Don't Ask, & Col
Apr 06, 2016 @ 15:38:01

The Full Stack Radio podcast has posted their latest episode, an interview with Michael Feathers (#39) talking about error handling, the "tell don't ask" principle and collection pipelines. Michael Feathers is the Director at R7K Research & Conveyance.

In this episode, Adam talks to Michael Feathers, author of Working Effectively with Legacy Code, about strategies for writing cleaner error handling code, the "tell don't ask" principle, and transforming data with collection pipelines.

You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to subscribe to their feed and follow the show on Twitter for updates when the latest show is announced.

tagged: fullstackradio ep39 michaelfeathers errorhandling telldontask collections podcast

Link: http://www.fullstackradio.com/39

HHVM Blog:
Improving Arrays in Hack
Nov 03, 2015 @ 17:46:14

On the HHVM blog there's a post talking about some of the updates they've made with array handling in Hack to help make it more efficient and overcoming some of the challenges in how they're being used.

Arrays are the ubiquitous data structure in PHP, used to represent everything from lists, associated lists, sets, tuples, or even a bag of data. This flexibility itself makes it challenging for Hack to understand how an array will be used. [...] If this was the only problem with PHP arrays, then the solution would be “simple”; make the type checker smarter (something we are working on). However there are a number of other semantic details around arrays that are nearly impossible to analyze statically.

They talk about some of the issues a bit more specifically including:

  • indexing of non-existent keys
  • key coercion
  • arrays containing references

They also talk about some of the legitimate use cases for arrays over the collections Hack offers, mostly do to with the values they could contain. The post ends with links to some of the other future improvements to the array handling in Hack and a look further out and their vision of replacing PHP arrays with Hack arrays and moving collections to a runtime library.

tagged: hhvm hack array improvement problem values collections

Link: http://hhvm.com/blog/10649/improving-arrays-in-hack

AWS Development Blog:
Preview the AWS Resource APIs for PHP
Jan 06, 2015 @ 16:32:37

On the AWS development blog Jeremy Lindblom has a recent post with a preview of the AWS resource APIs for PHP and the AWS SDK for PHP.

This year is just about over, but we are too excited to wait until the new year to share with you a feature we are developing for the AWS SDK for PHP. We are calling it the AWS Resource APIs for PHP. This feature is maintained as a separate package, but it acts as an extension to Version 3 of the AWS SDK for PHP.

He talks about the new resource objects that contain information to identify what it represented (like a S3 bucket or SQS queue) and includes an example object structure. He shows how to perform actions on the objects and working with collections. He also includes a helpful hint about using the "respondsTo" method on the object to get the methods the object can use.

tagged: aws resource api sdk update feature object actions collections

Link: http://blogs.aws.amazon.com/php/post/Tx3K1TS5GUKJR85/Preview-the-AWS-Resource-APIs-for-PHP

NetTuts.com:
Five Hidden Gems of Laravel
Aug 22, 2014 @ 16:51:20

The NetTuts.com site has posted a list of their five hidden gems in Laravel, a popular PHP framework. They look at a wide range of these "hidden" features that can help make your Laravel experience even better.

Many developers who use Laravel are probably only barely scratching the surface of what the framework has to offer. While the documentation does cover the most common use cases and the obvious features, it doesn’t cover everything. Don’t get me wrong, the documentation is fine, it’s just that there’s so much you can do, it’s hard to document everything. Because of that, we're going to take a look at some of the hidden gems that lurk within Laravel.

The five items on their list come complete with summaries about the feature, when they were added, if they're documented and a code sample with them in use:

  • Cascading Views
  • Collections (with sorting, filtering and pagination)
  • Regular Expression Filters
  • The Message Bag
  • Fluent
tagged: hidden gems laravel framework views collections regex filter message fluent

Link: http://code.tutsplus.com/articles/five-hidden-gems-of-laravel--cms-21907

ServerGrove.com:
MongoDB TTL collections
Aug 26, 2013 @ 14:30:47

On the ServerGrove blog today there's a new post talking about TTL collections in MongoDB - queries with a time-to-live set on the indexes - and includes how to use them in PHP.

MongoDB (v. 2.2+) provides a mechanism to expire data from collections by setting a TTL -time to live- on indexes. This is a great feature if you have data that needs to persist in the database for a specific period of time. The TTL feature allows you to expire data using the MongoDB daemon instead of having to create cron jobs to delete expired data. [...] The MongoDB daemon (mongod) checks regularly for documents in collections with a TTL and removes the expired documents.

Using it from PHP is relatively simple - all that's needed is a configuration parameter on the "ensureIndex" call setting an "expireAfterSeconds" value. There's also a bit included in the post for the Doctrine users out there, showing the docblock comment to use to set the value.

tagged: mongodb ttl timetolive collections expire seconds tutorial

Link: http://blog.servergrove.com/2013/08/23/mongodb-ttl-collections/

DevShed:
Collections and Sorting Continued
Apr 05, 2006 @ 12:13:17

Previously from DevShed, they started a series on collections and sorting in PHP. Today, they've posted part two of the series that builds on that and looks at sorting algorithm examples.

This article will examine the primary sorting algorithms with code examples, and some empirical data regarding how they perform in relation to one another, as well as the size of the data set in question.

We will also create a function to fill up our collection with random data in order to test the sort algorithms with a sufficiently large data set. The sort algorithms listed above are the ones that every computer science student learns in college and are the primary sort algorithms found in real-world applications.

The sorting styles they cover include: bubble sort, heap sort, merge sort, quick sort, and shell sort. For each, they provide the code, making it a simple matter of cut and paste to make it work in your script. There's not a whole lot of documentation going along with the code in this article, but the sorting code is simple enough to understand without it.

tagged: collections sorting bubble heap merge quick selection shell collections sorting bubble heap merge quick selection shell

Link:

DevShed:
Collections and Sorting Continued
Apr 05, 2006 @ 12:13:17

Previously from DevShed, they started a series on collections and sorting in PHP. Today, they've posted part two of the series that builds on that and looks at sorting algorithm examples.

This article will examine the primary sorting algorithms with code examples, and some empirical data regarding how they perform in relation to one another, as well as the size of the data set in question.

We will also create a function to fill up our collection with random data in order to test the sort algorithms with a sufficiently large data set. The sort algorithms listed above are the ones that every computer science student learns in college and are the primary sort algorithms found in real-world applications.

The sorting styles they cover include: bubble sort, heap sort, merge sort, quick sort, and shell sort. For each, they provide the code, making it a simple matter of cut and paste to make it work in your script. There's not a whole lot of documentation going along with the code in this article, but the sorting code is simple enough to understand without it.

tagged: collections sorting bubble heap merge quick selection shell collections sorting bubble heap merge quick selection shell

Link:

DevShed:
Collections and Sorting
Mar 29, 2006 @ 13:58:03

There are features in every language that developers love to have - in PHP, there are some impressive string and array handling functions that some developers would like to carry over. Unfortunately, there are also some bits of functionality that haven't quite made it to PHP yet - namely collections. In other languages, such as Java or C#, these handy containers let you hold objects for use later. PHP lacks this kind of functionality inherently, but this new DevShed article might just have a way around it.

A collection is an object whose primary function is to store a number of like objects. An object called CarCollection may contain any number of Car objects. Collections can traditionally be accessed in the same manner as arrays, which means CarCollection[n] represents a particular Car object. This is true in C#, Java, and more - but not PHP, unfortunately. Since PHP has only recently begun to develop a package of built in objects (the SPL, Standard PHP Library), the ability to support collections in the accepted behavioral sense is very limited.

Their mission is to work with a datatype that PHP does have to simulate this kind of collection handling - arrays. They walk you through the creation of a foundation class, one that simply allows you to get and fetch from the array. Extending that makes it possible to create a customized method for sorting personal data (name).

tagged: collections sorting array non-native objects collections sorting array non-native objects

Link:


Trending Topics: