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

Joe Fallon:
Immutable Objects in PHP
Aug 27, 2015 @ 11:53:36

Joe Fallon has a post to his site talking about immutable objects in PHP, objects that once the property values are set they cannot change.

When I first learned to program, I made many objects that were mutable. I made lots of getters and lots of setters. I could create objects using a constructor and mutate and morph the heck out of that object in all kinds of ways. Unfortunately, this led to many problems. My code was harder to test, it was harder to reason about, and my classes became chock full of checks to ensure that it was in a consistent state anytime anything changed.

[...] Now, I favor creating immutable objects. The folks over in the functional camp are super excited about this concept. However, it’s been around for quite a while and it has so many benefits.

He talks about how immutable objects make it easier to not only test code but also allow for more rational reasoning about their contents. He points out that they also make it easier to understand the state of an application should an exception arise. He then gets into some examples of immutable objects, creating an ImmutableClass and a ImmutableClassBuilder to help create instances based on values provided.

tagged: immutable object introduction class builder example benefits

Link: http://blog.joefallon.net/2015/08/immutable-objects-in-php/

David Sklar:
Fixing Broken UTF-8
Aug 27, 2015 @ 10:48:29

David Sklar has a post to his site showing you how to fix broken UTF-8 characters in content being passed through the normal string functions.

When working on the i18n bits of Learning PHP 7, I had a problem. My example showing how plain string functions such as strtolower() and strtoupper() mangle multibyte UTF-8 characters was making the book formatting/rendering pipeline barf. The processing tools are expecing nicely formatted, valid, UTF-8 encoded HTMLBook files. It didn’t like the mangled invalid UTF-8 characters in my example output.

To fix this, I wrote the following function to replace invalid UTF-8 sequences with the Unicode Replacement Character (U+FFFD).

He includes the code for this method that walks through the string, character by character, and checks the bytes it contains to see how it needs to be translated. There's plenty of comments in it too, explaining what it's doing as it goes along.

tagged: fix broken utf8 character function example unicode replacement

Link: http://www.sklar.com/php/2015/08/25/fixing-broken-utf8/

Zend Framework Blog:
Announcing Expressive
Aug 27, 2015 @ 09:41:21

The Zend Framework blog has posted an announcement about a new project they're offering to help make building PSR-7 middleware applications simpler - announcing Expressive.

We are pleased to announce the immediate availability of a new project, Expressive!

Expressive allows you to write PSR-7 middleware applications for the web. It is a simple micro-framework built on top of Stratigility, providing: dynamic routing, dependency injection via container-interop, templating and error handling.

The post helps you get a simple application using Expressive up and running via a Composer install and a bit of code. They talk about some of the goals behind Expressive, the interoperability it makes available and how it fits in with the Zend Framework ecosystem. They've released version 0.1.0 already and ask for testing (and bug reports) for this new framework. You can also check out the project documentation for more information about what it offers and the features currently implemented.

tagged: expressive framework psr7 middleware interoperability stratigility

Link: http://framework.zend.com/blog/announcing-expressive.html


Voices of the ElePHPant:
Interview with Josh Butts (#2)
Aug 26, 2015 @ 12:26:20

The Voices of the ElePHPant podcast has posted the latest episode in their series of interviews with members of the PHP community. In this latest episode host Cal Evans talks with Josh Butts, a developer from Austin, Texas and an organizer of the Austin PHP User group.

They talk about the presentation Josh gave at the Lone Star PHP Conference about "what your application is doing when you're not looking". Cal also asks Josh about a specific thing to keep an eye out for - in his example, it's handling exceptions thrown in your application correctly. They also talk about a presentation he presented at the Nomad PHP "virtual user group" about Redis (now passed, but you can find the video here).

You can listen to this latest episode either through the in-page audio player or by downloading the mp3. Also be sure to subscribe to their feed and follow them on Twitter to get information on the latest episodes as they're released.

tagged: voicesoftheelephpant community interview joshbutts podcast

Link: https://voicesoftheelephpant.com/2015/08/25/interview-with-josh-butts-2/

Community News:
SkiPHP Conference Call for Papers Deadline Coming Soon (Sept. 15th)
Aug 26, 2015 @ 11:13:03

The SkiPHP conference has posted a reminder to all of the speakers (or those wanting to become speakers) in the PHP community - their call for papers for the 2016 edition of their event ends on September 15th, just 20 days from today!

We are committed to getting the best speakers possible! To do that, we have arranged for a generous speaker package that makes it well worth our speakers' time. If one or more of your talks are accepted, and you commit to speak at Ski PHP, we will provide the following to you: a complimentary full ticket to the conference, three nights stay at a hotel, round-trip airline ticket to Salt Lake City, speaker dinner before the conference [and more].

If you're interested in submitting for the 2016 event, head over to their Call for Papers page on the conference website and submit now! If you just want to find out more about the conference check out the main conference site. Tickets aren't on sale just yet, but keep an eye on their Twitter account for information on when sales will open.

tagged: skiphp15 conference callforpapers submission cfp deadline saltlakecity utah

Link: https://www.skiphp.com/speak/package

Barry vd. Heuvel:
Comparing Blade and Twig templates in Laravel
Aug 26, 2015 @ 10:02:32

Anyone that has looked at using a templating library in their application has probably come across both Blade (in Laravel) and the Twig libraries. In a post to his site Barry vd. Heuvel compares these two templating libraries based on their features, security and (briefly) performance.

In my company, we use Twig instead of Blade for our Laravel projects. I know there are a lot of developers that also prefer Twig over Blade. So the question ‘Why choose Twig over Blade?’ often pops up. The reason is usually just a matter of preference, but in this post we’re going to compare the Blade and Twig templating engines side-by-side.

He starts with an "about" for each library, giving some basic background and examples of simple templates. He talks about using Twig in Laravel (vs Blade) and then lists some similarities and differences between the two. Following this high-level list he gets into more detail on each feature of the libraries including:

  • Outputting variables
  • Control structures
  • Template inheritance and sections
  • Security and context

Each section includes a description of the feature and a template example showing how it's put to use. He ends the post with his thoughts on which one you should pick for your project, but notes that, like many things in development, the answer is "it depends" on your project and team's needs.

tagged: compare blade template twig library feature overview example

Link: http://barryvdh.nl/laravel/twig/2015/08/22/comparing-blade-and-twig-templates-in-laravel/

Vertabelo.com:
ORMs under the hood
Aug 26, 2015 @ 09:55:01

The Vertabelo site has posted a tutorial that gives you an "under the hood" view of ORMs and what they're doing in the background to help make accessing your database information easier.

It often happens that if something is loved, it is also hated with the same power. The idea of object relational mapping fits into this concept perfectly. You will definitely come across many opposite points and fierce discussions as well as unwavering advocates and haters. So if you have ever asked whether to use ORM or not, the answer “it depends” will not be enough.

They start with a definition of an ORM to get everyone on the same page, highlighting how they represent database contents and what some of the benefits are in using them. From there the article talks about the importance of good SQL and a few common dangers in using an ORM and not knowing SQL. Then the article gets into how ORMs work and some of the common design patterns they can implement. It lists some of the more popular ORMs (for Python, Java and PHP) and covers some of the main disadvantages to their use. The article ends with examples of some of the libraries mentioned, highlighting the Propel ORM for the PHP world.

tagged: orm behindthescenes introduction advantages disadvantages types propel example

Link: http://www.vertabelo.com/blog/technical-articles/orms-under-the-hood

PHP Roundtable:
029: The Only Girl In The Room
Aug 26, 2015 @ 08:36:35

The PHP Roundtable podcast, hosted by Sammy K Powers, has released their latest episode today with guests Beth Tucker Long, Eyrn O'Neil and Samantha Quiñones - Episode #29: The Only Girl in the Room

Inspired by a panel discussion at Midwest PHP 2015, we discuss what barriers exist for women in the PHP community and what we can all do to remove gender bias.

You can listen to this latest episode either through the in-page video player or directly over on YouTube. If you enjoy the episode be sure to subscribe to their feed and follow them on Twitter to get information about future episodes as they're released. You can also catch previous episodes by going to the main page of the site and scrolling through the "Past Episodes" section.

tagged: phproundtable podcast video girl female technology barriers gender bias

Link: https://www.phproundtable.com/episode/being-a-woman-in-the-php-community

Community News:
Recent posts from PHP Quickfix (08.26.2015)
Aug 26, 2015 @ 07:53:58

Recent posts from the PHP Quickfix site:

tagged:

Link: