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

Matt Stauffer:
Advanced operations with Collection::where in Laravel 5.3
Jul 15, 2016 @ 16:35:44

Matt Stauffer has continued his series looking at new features in Laravel 5.3 with a look at advanced operations on collections, specifically related to the "where" handling.

If you want to filter a Laravel collection to only those records which meet particular criteria, you're most likely going to reach for filter() or reject(). [...] You might not know it, but there's also a where() method that's pretty simple that gives you the same functionality.

He points out the main difference in Laravel 5.3 - the change from a strict check (the ===) to looser checking (==) and the ability to modify the operation to your liking. He also links to more information about this and other methods in the Laravel code on GitHub.

tagged: laravel collection where laravel53 feature series part6

Link: https://mattstauffer.co/blog/advanced-operations-with-collectionwhere-in-laravel-5-3

Matthew Weier O'Phinney:
Deployment with Zend Server (Part 6 of 8) - Page Caching
Sep 11, 2014 @ 19:57:08

Matthew Weier O'Phinney has posted his sixth part (of eight) in his "deployment with Zend Server" tips and tricks. In this latest post he talks about page caching.

This is the sixth in a series of eight posts detailing tips on deploying to Zend Server. The previous post in the series detailed setting job script status codes. Today, I'm sharing some tips around setting up page caching, and jobs for clearing the Zend Server page cache.

He starts off describing what Zend Server offers in the way of page caching and provides an example (with screenshots) of how he sets his up to work with multiple subdomains. He then shows how to set what variable the caching looks at to tell the difference between pages and how to clear the cache on deploy. He includes a simple script to help with that, running through a list of paths and calling the flush on each.

tagged: zendserver deployment tips series part6 page caching

Link: https://mwop.net/blog/2014-09-11-zend-server-deployment-part-6.html

NetTuts.com:
Refactoring Legacy Code: Part 9 - Analyzing Concerns
Jul 24, 2014 @ 16:27:56

The NetTuts.com site has posted part nine in their series sharing helpful hints and methods for refactoring legacy code. In this new post they continue on with their example application and look at where methods should be moved to/created and mocking in their tests.

In this tutorial, we will continue to focus on our business logic. We will evaluate if RunnerFunctions.php belongs to a class and if so, to which class? We will think about concerns and where methods belong. Finally, we will learn a little bit more about the concept of mocking.

They show how to move some of the "Runner" functions from procedural to OOP, integrating them with some of the classes and methods that already exist. Tests are also included showing how it all links together. From there they get into concerns about the placement of functionality and how that relates to the work at hand. They also use Mockery to mock out some of the needed objects in their tests for the new structure.

tagged: refactor legacy code series part6 concerns functionality mock unittest

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-9-analyzing-concerns--cms-21760

NetTuts.com:
Refactoring Legacy Code: Part 6 - Attacking Complex Methods
Jun 27, 2014 @ 18:17:37

The NetTuts.com site has posted the sixth part in their "Refactoring Legacy Code" series, this time with a focus on the more complex methods. They look at simplifying their contents and testing their various parts (better code coverage). The post is based completely on the contents of the previous five in the series, so if you haven't read up on those do that before starting.

In our previous five lessons we invested quite a lot of time in understanding our legacy system, in writing tests for whatever testable piece of code we could find. We reached a point to where we have quite a few tested methods but we still avoided the complex, hard to understand logic. It's now time for some serious coding.

The start with one of the more complex methods (roll) and work through it line-by-line to figure out what it's being given, how it's handling the data and what kinds of things it might return or modify inside. The break it down into to "parts" and figure out the right tests to write for each. With the method fully tested, they then start in on the refactor, teasing out various parts of the method into other methods and property changes. There's also a section at the end talking about pair programming and how it relates to good testing practices.

tagged: refactor series tutorial part6 complex method unittest phpunit

Link: http://code.tutsplus.com/tutorials/refactoring-legacy-code-part-6-attacking-complex-methods--cms-21522

Dutch Web Alliance:
The definitive remote debug and unittest with PHPStorm guide: part 7
Jan 29, 2014 @ 16:54:25

The Dutch Web Alliance has posted the seventh part of their series looking at getting remote debugging and unit testing working with PHPStorm, a popular PHP IDE. You can start at the beginning or just find the links to any other articles in the series you might have missed in the first post.

So, your unit-tests should be small, not doing much, taking one unit at a time to test. Overall, not much is around to actually debug. But on occasion, having the ability to actually stepping through the unit-tests can save you a headache or two! Debugging your PHPUnit scripts isn’t really that hard. In fact, most of what we need to do, we already covered in the previous postings! Consider this: PHPUnit is nothing more than a PHP framework running from the command line interface. And since we already know how to debug applications from the CLI, it must be easy!

This is the last post in the series and is pretty short. It basically talks about setting breakpoints in testing and letting PHPStorm catch the issues. If you'd rather run them from the command line, check out part six for more details.

tagged: debugging unittest remote phpstorm tutorial series part6

Link: https://dutchweballiance.nl/techblog/the-definitive-remote-debug-and-unittest-with-phpstorm-guide-part-7/

Dutch Web Alliance:
The definitive remote debug and unittest with PHPStorm guide: part 6
Jan 09, 2014 @ 17:20:28

The Dutch Web Alliance has posted the sixth part of their series helping you debug/unit test your applications with PHPStorm and Xdebug. In this new post they focus on working with command-line applications.

So there is already a lot covered: debugging web applications, testing your units, getting code coverage. But one thing that remains is trying to debug your command line applications. Even today more and more applications aren’t built for primarily the web, but for other purposes or many web frameworks have some kind of “console” component which allows you to easily create command line tools that deals with asynchronous handling of data, or just mere as cronjobs.

They walk you through the steps you'll need to be sure everything it set up correctly for PHPStorm to catch the debug calls:

  • Ensuring Xdebug is active
  • Validating that PHPStorm is listening for incoming requests
  • Configuring Xdebug on where to connect
  • Setting up the mapping for paths inside PHPStorm
tagged: xdebug phpstorm unittest debug tutorial series part6 commandline

Link: http://dutchweballiance.nl/techblog/the-definitive-remote-debug-and-unittest-with-phpstorm-guide-part-6/

Zend Developer Zone:
AJAX Chat Part Tutorial 6 : Updating the User List
Jan 08, 2007 @ 19:14:00

The Zend Developer Zone has posted the second to last part of their Ajax chat tutorial today. This time, they focus on updating the list of users currently in the chat.

Updating the user list should occur whenever the user adds a new chat message or refreshes the chat window. Since we already use the MessageAction() method on our PHP IndexController class to forward such responses to the browser, we'll simply amend it to also return a list of currently online users.

They start by altering the MessageAction controller to handle the fetching of online users and split out the code to grab the latest messages into a getNewMessages function. They check who is online by looking at the last messages to the queue (not reliable, but about as good as it can get with a stateless protocol). Finally, they update the handleRefresh method to execute the new "find online users" code as pass it on to the output view.

tagged: ajax chat tutorial part6 user list online ajax chat tutorial part6 user list online

Link:

Zend Developer Zone:
AJAX Chat Part Tutorial 6 : Updating the User List
Jan 08, 2007 @ 19:14:00

The Zend Developer Zone has posted the second to last part of their Ajax chat tutorial today. This time, they focus on updating the list of users currently in the chat.

Updating the user list should occur whenever the user adds a new chat message or refreshes the chat window. Since we already use the MessageAction() method on our PHP IndexController class to forward such responses to the browser, we'll simply amend it to also return a list of currently online users.

They start by altering the MessageAction controller to handle the fetching of online users and split out the code to grab the latest messages into a getNewMessages function. They check who is online by looking at the last messages to the queue (not reliable, but about as good as it can get with a stateless protocol). Finally, they update the handleRefresh method to execute the new "find online users" code as pass it on to the output view.

tagged: ajax chat tutorial part6 user list online ajax chat tutorial part6 user list online

Link:

IBM developerWorks:
Understanding the Zend Framework (Parts 5 & 6)
Aug 23, 2006 @ 12:50:01

The IBM developerWorks site has continued on with its "Understanding the Zend Framework" series with spotlights on two new bits of functionality - creating PDFs and sending emails from inside the framework.

In this part of the series (part 5) they show how to:

  • create PDFs
  • use positioning in adding text, graphics, and shapes to the document
  • manage long blocks of text
  • stream out a dynamic PDF to the browser
  • add information to an existing PDF document

Part six picks up where the previous part left off and includes information on working with emails in the Zend Frameork. They look at the Zend_Mail component and, making some minor changes to the application they've been constructing (the feed reader). They create an email notification to the user when a feed has been updated.

Code examples and the source code for both of these sections are provided.

tagged: understanding zend framework part5 part6 email pdf create feed understanding zend framework part5 part6 email pdf create feed

Link:

IBM developerWorks:
Understanding the Zend Framework (Parts 5 & 6)
Aug 23, 2006 @ 12:50:01

The IBM developerWorks site has continued on with its "Understanding the Zend Framework" series with spotlights on two new bits of functionality - creating PDFs and sending emails from inside the framework.

In this part of the series (part 5) they show how to:

  • create PDFs
  • use positioning in adding text, graphics, and shapes to the document
  • manage long blocks of text
  • stream out a dynamic PDF to the browser
  • add information to an existing PDF document

Part six picks up where the previous part left off and includes information on working with emails in the Zend Frameork. They look at the Zend_Mail component and, making some minor changes to the application they've been constructing (the feed reader). They create an email notification to the user when a feed has been updated.

Code examples and the source code for both of these sections are provided.

tagged: understanding zend framework part5 part6 email pdf create feed understanding zend framework part5 part6 email pdf create feed

Link:


Trending Topics: