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

Laravel News:
Route improvements are coming to Laravel 5.4
Dec 07, 2016 @ 16:12:31

The Laravel News site has a quick new post about some routing improvements that are coming in the next larger release of the framework , Laravel v5.4:

As Laravel 5.4 development continues, two new improvements are coming to your routes, better route caching for large applications and fluently registering routes.

The route caching updates will help performance with larger applications, reducing the parsing time required to locate and push a request to the right location. The "fluent" route improvements basically allow for the definition of some things, like middleware or route names, as a part of the route definition rather than after the fact. Examples of this are included in the post.

tagged: laravel routing improvement v54 cache fluent registration

Link: https://laravel-news.com/route-improvements

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

Brandon Savage:
The value of design patterns
Oct 21, 2013 @ 17:48:37

Brandon Savage has a new post today talking about the value of design patterns with his response to another post. He tries to put the emphasis back on making good OOP code instead of worrying too much about the actual design pattern.

Anthony [Ferrara] makes some great points in his article, and I highly encourage you to read it. But I want to address the perspective that he puts forward, which is that worrying about design patterns is less important than worrying about writing great object oriented code.

He relates design patterns to the sentence structures you learn when learning a new (spoken) language. He suggests that, while they're a good way for developers to communicate, they shouldn't be the only emphasis. When a developer becomes more fluent in a language, the patterns should become less important but are still a good structure for good development practices.

tagged: oop designpattern value opinion fluent language

Link: http://www.brandonsavage.net/the-value-of-design-patterns/

Procurios Tech Blog:
Autocompleting a lot of parameters
Oct 16, 2013 @ 16:14:05

Pim Elshoff has a recent post on the Procurios tech blog looking at autocompletion on function calls and an alternative to the "too many parameters" problem.

Some methods have many parameters. Sometimes they start out like that, sometimes they grow like that over time. Even though a maximum of two parameters is preferable, configuration for a method that does a big thing is difficult. Take curl for example; curl has a lot of options and so several wrappers around curl have arisen to deal with configuring it in a more humane manner. How can we keep the clutter of many parameters as low as possible, while maintaining autocompletion?

He gives an example of a function that takes too many arguments and how it's difficult to read (and remember the right order/types to give). He does mention one way that's sometimes used - arrays - but you lose typing checks with that. His best recommendation is to use a fluent interface instead. Not only does it make it more readable but it also works with the autocompletion in most IDEs.

tagged: autocomplete parameters suggestion array fluent interface

Link: http://tech.procurios.nl/archief/2013/10/11/Autocompleting-a-lot-of-parameters

WebSpeaks.in:
Learn Simple Method Chaining in PHP
Feb 22, 2011 @ 17:09:13

On WebSpeaks.in today there's a recent post that introduces you to something more and more applications are using - especially frameworks - method chaining in PHP OOP apps.

In this article we will learn an advanced OOPS programming concept in PHP known as Method chaining. If you have worked on PHP frameworks like Zend, Magento or CakePHP, you might have noticed a very convinient style of accessing methods of different classes. [...] This type of programming technique is known as method chaining. If you are thinking how is it possible to perform this chaining, then don't worry. Today we will learn this fancy concept.

They create a simple class, a Person, and show the difference between calling several methods on the created object versus a method chained example that calls all three, making updates to the object itself ($this). There's also a bit more complicated example with three different classes in the mix.

tagged: method chaining tutorial object fluent

Link:

Mark van der Velden's Blog:
PHP Quiz part 4
Nov 02, 2010 @ 17:05:46

If you were a fan of the PHP quizes that Mark van der Velden has posted in the past, you'll be happy to know he's come back with part four of the series after a bit of a hiatus.

It has been a while, but here is part 4 of the PHP Quiz series! A few questions to crack your brain about, or perhaps you know them all? Try them and find out! Also do read the idea behind these quizzes, here: The PHP Quiz series

In this quiz he tests your knowledge of class visibility, fluent method handling, class extension, strptime and a tricky "for" loop. Take the quiz and see how you do.

tagged: quiz fluent visibility strptime extension

Link:

Jani Hartikainen's Blog:
Using a builder to construct complex classes
Apr 02, 2009 @ 17:58:28

If your code is getting more and more complex all the time and you find yourself creating a similar group of objects over and over, you might check out Jani Hartikainen's latest advice and create a "builder" around them.

Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters. [...] Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters.

His example is a "message builder" wrapper that lets you specify the receiver, sender and message and inject them into a to() method call (with a fluent interface). He shows how to make sure that the object you need (the message object) is always complete.

tagged: fluent interface builder class complex tutorial

Link:

ProDevTips Blog:
Fluent Arrays and Strings in PHP - Adding JSON and more
Jul 17, 2008 @ 14:32:26

Henrik continues his look at fluent arrays and strings in PHP with this second part of his series, adding JSON functionality into the mix.

Recently I've had the need to extend the interface further, among other things with JSON support. I've used code published by Nicolas Crovatti to do this.

His example shows how the script works to plot out some points for a table of stats. He follows this with an in-depth look at the different methods making up that fluent call (apply2Field, fill_ret, sum and plot). These make the array that can then be passed off to PHP, using json_encode to make an easy-consumable JSON message out of the results.

tagged: json fluent array string php5 tutorial jsonencode

Link:

ProDevTips Blog:
Fluent Arrays and Strings in PHP
Jun 23, 2008 @ 12:57:18

On the ProDevTips blog, Henrik has written up an extensive tutorial with plenty of code examples on working with something inspired by a few other languages - fluent arrays and strings.

I've been working some with jQuery and Ruby lately, as you might know they both have very neat fluent interfaces for writing short and easily understandable code. Especially Ruby's array and string handling should be something that can be done in PHP so I started googling. [...] It's probably very possible that what I'm looking for is already part of some PHP framework or such but I didn't want to spend more time looking than being productive.

Based on some Ruby examples, he defines a set of functions that can be use to create these fluent interfaces to the common PHP variable types (contained in a class for easy use). The entire source can be downloded here.

tagged: fluent string array class source download tutorial

Link:

Zend Developer Zone:
Designing Klingon Warships Using Behaviour Driven Development
Feb 11, 2008 @ 21:34:00

The Zend Developer Zone has another new tutorial from Padraic Brady talking about testing your applications (i.e. unit tests). In this new article, he expands on his previous one and dives a bit deeper into the behaviour-driven development process.

In this article, I introduce a TDD related practice called Behaviour-Driven Development which has been gathering attention for over a year and gaining converts (like me!).

He briefly covers what BDD is and how it can be used to solidify code against issues that might come up down the road (and how it compares to test-driven development). Some sample code/tests are included to give you a better idea of how it all fits together - a set of scenarios for any given "story". True to the title, Padraic writes his tests around the construction of a Klingon Bird of Prey ship.

tagged: birdofprey behavious driven development unittest fluent plain english

Link:


Trending Topics: