Nate Krantz: How I’m Writing Unit / Functional Tests

In a recent post Nate Krantz has shared some of his own methods around writing functional and unit tests.

So…testing. That thing that everyone says is so important but you don’t really learn about it in school. I’ve had some trials and tribulations with testing so I’m going to just dump out some thoughts here.

He starts with a bit of background on his own experiences in development and how he finally decided that testing would “solve everything”. He started with unit tests (for a CodeIgniter application) and how he got them up and running. He talks about issues he found around dependencies (and static methods) and how he made use of mocks to reduce some of the issues with dynamic loading, at least how CodeIgniter does it. Unfortunately, this didn’t work out as planned so he fell back to a test database and create more effective and simpler functional tests. Code examples are sprinkled through out the post to show how he was trying to solve the problem at different points in the process.

Link: http://www.natekrantz.com/why-test-driven-development-rocks-sucks/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , | Hinterlasse einen Kommentar

Ross Tuck: How I Use Traits

Ross Tuck has posted a new article to his site today talking about how he uses traits in his applications and where he sees them having the most value.

Recently, a few folks asked about a trait in a new project I wrote. Right around the same time, Rafael Dohms showed me his new talk about complex cognitive processes we don’t notice. Because my brain is a big mushy sack, the two blended together. The result was this post, which tries to capture how I use traits but also how I decide to use them in the first place.

He starts off with a bit of talk about leverage versus abstraction and how the concepts relate to code. He includes a brief example of each and points out that, while each is good, abstraction tends to be more useful. He then applies this back to the world of traits, how they compare to the use of normal static methods and how they have an advantage of encapsulation without oversharing. He suggests that assertions are more fit as static methods and that traits are a better fit in cases where multiple inheritance is needed. He also touches in interfaces in traits and his opinion on when is the best time to use them.

Link: http://rosstuck.com/how-i-use-traits/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , | Hinterlasse einen Kommentar

Laravel Podcast: Episode 27 – Jeffrey Way: Tau Ceti Murderer

The Laravel Podcast, with host Matt Stauffer and guests Taylor Otwell and Jeffrey Way, has posted their latest episode (#27): Jeffrey Way: Tau Ceti Murderer.

This week the crew discusses new Laravel 5.1 goodies, unit testing, Lifeline for iOS, and which album they would take to a desert island.

You can listen to this new episode using the in-page audio player or by downloading the mp3. If you enjoy the show, be sure to subscribe to their feed too and get more great episodes as they’re released.

Link: http://www.laravelpodcast.com/episodes/11430-episode-27-jeffrey-way-tau-ceti-murderer
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , | Hinterlasse einen Kommentar

SitePoint PHP Blog: More Effective PHP Logging with Loggly

The SitePoint PHP Blog has a new tutorial by Yones Rafie showing you how to log more effectively with Loggly, a remote log management service that’s easy to connect to your PHP application. (Note: this post is sponsored by Loggly but it’s still an interesting tool.)

When logging with PHP, we tend to use the error_log and trigger_error functions, or we can use an error handler to make the logging process more generic. […] But what would you do if you had to log to multiple places at the same time, or you were sending logs to a given service depending on the error level? Rather than using built-in tools, it’s often easier to use logging libraries.

They go on to talk about logging using a PSR-3 compliant logger and show how to integrate the Loggly service with your application via one of the most popular options, Monolog. The integration is made even easier by the fact that Monolog already comes with a LogglyHandler built-in. The post includes the code you’ll need to implement the logger, how to integrate it with a Laravel application, setting it up on Heroku and and a tour of the Loggly features for filtering, searching and examples of the graphs showing query results. Loggly is free to try out, so you can see if it will work for your application before making the commitment.

Link: http://www.sitepoint.com/effective-php-logging-loggly/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , | Hinterlasse einen Kommentar

Knp University: Symfony Service Expressions: Do things you thought Impossible

The Knp University site there’s a new post showing you an interesting thing you can do with Symfony2 service definitions – use more complex expressions to load and supply service dependencies.

[Using] the @= means that you’re using Symfony’s Expression Language, which let’s you mix dynamic logically into your normally-static service definitions. Normally, if you want to inject a repository, you need to register it as a service first, using a factory. And while that’s fine (and probably better if you’re injecting the factory a lot), using the expression language is well, kinda cool.

They include an example of the compiled container code that would be produced from the example expression. They also show how to use the same expression language to read configuration information and pass it in as an argument to the created service. The show the pull of a configuration setting “email_from_username” and how to inject it via the expression language.

Link: http://knpuniversity.com/blog/service-expressions
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , | Hinterlasse einen Kommentar

PHP Roundtable: 019: The Business of PHP

The PHP Roundtable podcast has posted their latest episode hosted by Sammy Powers and featuring guests Michael Kimsal, Gary Hockin, Yitzchok Willroth and Matt Stauffer. In this new episode they talk about the “Business of PHP”.

We discuss freelancing as a PHP developer, managing client expectations, niches, good customer service, project scope & scope creep, hourly rates vs value based pricing, and whether or not to run a SaaS.

You can catch this latest episode either through the in-page video player or by heading over to YouTube and catching the video there. If you enjoy the roundtable, be sure to subscribe to their feed.

Link: https://www.phproundtable.com/episode/the-business-side-of-php-clients-customer-service-pricing-oh-my
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , | Hinterlasse einen Kommentar

Engine Yard Blog: Composer & Continuous Integration

In a new post to the Engine Yard blog Nils Adermann provides an overview of using Composer with continuous integration, its role in the overall process and some good practices to follow in its use.

Continous Integration (CI) is the practice of continuously (and automatically) testing every change a developer makes. So automated tests become an integral part of the development process providing direct feedback on changes made. […] Davey Shafik’s article on Composer’s Lock File explains the typical usage of composer install and update. The key takeaway is that developers should run composer update manually to explicitly update individual dependencies while composer install should be used in automated processes. This principle includes automated test environments.

He points out that using the lock file method reproduces the vendor directory exactly as it is in production and what it means for failures in your automated tests. He also talks about methods to improve the build performance to reduce time spent during the generation of the environment, including the use of the Composer cache data. He includes a few flags you can pass to Composer to reduce not only the libraries it installs but also how it fetches their contents.

Link: https://blog.engineyard.com/2015/composer-continuous-integration
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , | Hinterlasse einen Kommentar

DigitalOcean Community Blog: Horizontally Scaling PHP Applications: A Practical Overview

On the Digital Ocean blog there’s a new post with a “practical overview” of how to effectively scale PHP applications, specifically as it relates to horizontal scaling not vertical.

Shipping a website or application to production has its own challenges, but when it gets the right traction, it’s a great accomplishment. It always feels good to see the visitor numbers going up, doesn’t it? Except, of course, when your traffic increases so much that it crashes your little LAMP stack. […] But fear not! There are ways to make your PHP application much more reliable and consistent. If the term scalability crossed your mind, you’ve got the right idea.

The article starts with a brief overview of what scalability is and the main difference between horizontal and vertical scaling (scaling out vs scaling up). They then get into a bit more detail about what horizontal scaling is and how it commonly works in relation to the average PHP application (complete with diagrams). They also talk about some things you can do inside your code to help make things flow a bit more smoothly including decoupling between services and user session/file consistency measures. There’s also a bit at the end about load balancing but as that depends a good bit on what technology you’re using and the actual load, they just provide an overview and some links to other articles and tutorials with more information.

Link: https://www.digitalocean.com/company/blog/horizontally-scaling-php-applications/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , , | Hinterlasse einen Kommentar

PHP.net: PHP 5.6.8, 5.5.24 & 5.4.40 Released (Security Fixes)

The PHP development group has released several different versions of PHP for the 5.5.x, 5.6.x and 5.4.x series with a long list of security issues fixed in each one (fourteen in total):

The PHP development team announces the immediate availability of PHP [5.4.40, 5.6.8, 5.5.24]. 14 security-related bugs were fixed in this release, including CVE-2014-9709, CVE-2015-2301, CVE-2015-2783, CVE-2015-1352. All PHP 5.4 users are encouraged to upgrade to this version.

Other items were fixed besides the security issues, so check out the Changelog to see those few other fixes. It’s highly recommended that you update your installations to these latest versions. You can grab the latest either from the downloads page (source) or Windows users can go to winodws.php.net.

Link: http://php.net/archive/2015.php#id2015-04-16-3
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , | Hinterlasse einen Kommentar

Made With Love Blog: Tilde and caret version constraints in Composer

The Made With Love blog has posted a great introduction to version handling in Composer today. They focus in on two characters that can be confusing if you’re not exactly sure what they mean – the carat (^) and tilde (~).

A dependency that uses semantic versioning allows you to predict wether it is still going to work or not when you upgrade it to a new version. Basically when the x in a x.y.z version number changes, you might need to do some changes to be able to work with this new version without problems. […] Depending on your dependency manager you can define version constraints using wildcards (*), comparators like < =, logical operators (, often means AND and | means OR), etc. [...] There are also some syntactic sugar operators like ~ (tilde) and ^ (caret)

They include some examples of both characters in use defining the required install versions, showing how one allows for approximate matches and the version ranges they apply to.

Link: http://blog.madewithlove.be/post/tilde-and-caret-constraints/
PHPDeveloper.org

Veröffentlicht unter Allgemein | Verschlagwortet mit , , , , , , , , | Hinterlasse einen Kommentar