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

Tomas Votruba:
Collector Pattern for Dummies
Jun 15, 2018 @ 14:03:13

In a new post to his site Tomas Votruba comes back to a topic he posted about previously - the collector pattern - and provides a simpler, more introductory look at the pattern and what it's useful for.

I wrote Why is Collector Pattern so Awesome a while ago, but I got feeling and feedback that it's way too complicated.

The pattern itself is simple but put in framework context, it might be too confusing to understand. That's why we look on collector pattern in minimalistic plain PHP way today.

He uses a calculator example help explain the use of the pattern, starting with a simple class that calculates the price of a product + VAT. He then shows a few examples of how it could grow over time as business requirements change. He refactors the class to make it easier to add in these one-off changes by setting them all as "calculators' in a calculator collection. He provides the code examples for this refactor and an example of it in use.

tagged: collector pattern introduction calculator tutorial

Link: https://www.tomasvotruba.cz/blog/2018/06/14/collector-pattern-for-dummies/

Laravel News:
Testing With PhpSpec
Sep 18, 2017 @ 15:22:26

On the Laravel News site there's a new tutorial posted introducing you to testing with PhpSpec, a specification-driven testing tool that helps you model the specification your application needs to match.

PhpSpec is a testing tool based on the concept of emergent design using specification. You may have heard of Behavior Driven Development (BDD), and PhpSpec is a tool to use at the spec level or SpecBDD. We also mentioned PhpSpec in our recent roundup of Laravel Testing Resources, which includes ways you can incorporate PhpSpec into your Laravel workflow if you are interested in trying out SpecBDD.

If you’ve never tried PhpSpec, one of the things that I love about PhpSpec is that the process generates code for you and guides you through the SpecBDD process through the command line. Let me show you what I mean with a quick tutorial.

The tutorial then walks you through the installation of PhpSpec and how to run it from the command line before making any tests. They then walk through the configuration of the tool and share a sample workflow with seven steps including describing a specification, writing out expected behavior and verifying the behavior. Code examples (and command line calls) are included in each step of the way, defining an example "calendar" specification with the common functionality (add, subtract, divide, etc). The post finishes with some links to where you can find more information about PhpSpec and spec driven development.

tagged: phpspec specification testing calculator tutorial development

Link: https://laravel-news.com/testing-with-phpspec

Marc Gear's Blog:
How to learn a new PHP framework
Dec 11, 2008 @ 16:20:28

In this new blog entry Marc Gear suggests a few things that you can do to help learn a new framework quickly and easily:

There are dozens of PHP frameworks around now, some attracting more attention than others. I am no expert on these frameworks and have not used a single one extensively so I wouldn't dream of recommending one over the other, nor do I want to enter the debate about what is or is not a framework (I'll work on the assumption that anything calling itself a framework is a framework). Instead I'm going to concentrate on how you can get started with a new framework as quickly as possible.

He suggests four examples that can help you get more familiar with each framework and how they're structured - a "hello world" as a first step, creating a simple calculator, making a guestbook and making a simple script to parse and paginate a remote RSS feed.

tagged: learn framework helloworld calculator guestbook rss parse page

Link:

Adam Trachtenberg's Blog:
Stupid PHP one liners: Google calc
Aug 24, 2006 @ 12:22:10

One-liners can sometimes be quite helpful in your programming, and in hopes it will help someone out there out, Adam Trachtenberg shares one of his own in his latest blog entry today.

A long time ago, I wrote a two line hack that let you use Google as a command line calculator. It eventually ended up in the 2nd and 3rd editions of Google Hacks.

The code calls the Google Calculator page and pulls back in the contents, allowing you to pass in any sort of calulation you might want and pass back out the result all cleaned up and parsed out.

tagged: oneline google calculator commandline file_get_contents regular expression oneline google calculator commandline file_get_contents regular expression

Link:

Adam Trachtenberg's Blog:
Stupid PHP one liners: Google calc
Aug 24, 2006 @ 12:22:10

One-liners can sometimes be quite helpful in your programming, and in hopes it will help someone out there out, Adam Trachtenberg shares one of his own in his latest blog entry today.

A long time ago, I wrote a two line hack that let you use Google as a command line calculator. It eventually ended up in the 2nd and 3rd editions of Google Hacks.

The code calls the Google Calculator page and pulls back in the contents, allowing you to pass in any sort of calulation you might want and pass back out the result all cleaned up and parsed out.

tagged: oneline google calculator commandline file_get_contents regular expression oneline google calculator commandline file_get_contents regular expression

Link:


Trending Topics: