PHP Tip of the Week: Code as Config

This week’s tip is going out to both Nomad PHP and Nomad Mage because the person who wrote the blog post is an active member of both communities.

Stephan Hochdörfer recently penned short blog post introducing an interesting concept that he and bitExpert are espousing. Forget XML (or YAML, or JSON, or any other markup language) store your config files in PHP code. This is an interesting concept to me. I’ve done this in the past but I’ve also used YAML and JSON. (I refuse to use XML for anything)

If you are curious, check out his blog post “Why using code as DI config is a win!”. It doesn’t matter if you like the idea or not. All that matters is that you understand the idea before you decide. 🙂

Don’t miss out on any PHP tips!

Did you know that we post tips like this every single week to our newsletter? Each Tuesday we send you a short post about something that we know you will find informative and useful. Fill out the form below and join the World Wide Herd today. Don’t be the only one who doesn’t know.

 


 

Code as Config

This week’s tip is going out to both Nomad PHP and Nomad Mage because the person who wrote the blog post is an active member of both communities.

Stephan Hochdörfer recently penned short blog post introducing an interesting concept that he and bitExpert are espousing. Forget XML (or YAML, or JSON, or any other markup language) store your config files in PHP code. This is an interesting concept to me. I’ve done this in the past but I’ve also used YAML and JSON. (I refuse to use XML for anything)

If you are curious, check out his blog post Why using code as DI config is a win! It doesn’t matter if you like the idea or not. All that matters is that you understand the idea before you decide. 🙂


Join the Word Wide Herd!

Each week we send a tip, trick, or new project to PHP developers around the world. Don’t be left out. Join the Nomad PHP mailing list today and be a part of the World Wide Herd.

* Fine print. We do not sell, rent, loan, or otherwise distribute your information to anyone, ever.

Symfony Social Stats

Recently my good friend Ryan Weaver of KNPLabs released a very interesting page of statistics for the Symfony framework. The page titled “Symfony Trends” shows pretty graphics of some of the non-traditional statistics. Most of the time when we look at framework stats they are things like page load time and pages per second, the usual things that we use to compare frameworks with each other. The page Ryan shared gives interesting stats like:

  • How many developers contribute to different projects
  • Where Symfony contributors live and work
  • Commit count to Symfony code per year

These are all social stats. They show a very important metric, size and involvement of the community. I used to have a talk called “5 Things I Wish They Had Told Me About PHP Before I Started.” The first point was select a framework and one of the points of comparison I gave was size of the community. The size and involvement of the community is a very important metric when considering a framework. Ryan has made it easy to consider the Symfony community.

Cheers!
=C=

Cal Evans
Nerd Herder to the World Wide Herd

Framework Porn

(No, not really porn. Totally SFW) 

Today Taylor Ottwell, creator of the Laravel framework, posted the Framework Code Complexity Comparison. For those not familiar with “Cyclomatic Complexity” here’s the Wikipedia page Cyclomatic Complexity. Briefly, “Cyclomatic Complexity is a software metric (measurement), used to indicate the complexity of a program.”

While Taylor’s post gives you the complete breakdown, here are the average method complexity scores for each framework tested. (Lower is better)

Laravel 1.62
Symfony 1.88
Slim 2.40
Zend 2.76
CakePHP 3.30

Taylor also compares Laravel’s Eloquent ORM to Doctrine. Since I think ORMs are evil, I won’t list those scores here. You can read them on the blog post though.

Cyclomatic Scores are not the end-all, be-all comparison of frameworks. They are however an interesting fact to consider when looking at a framework. Less complex framework code usually means less complex application code.

If you are interested in testing your own project’s Cyclomatic Complexity score, you will need PHP Mess Detector installed and up and running. Check out Leonid Mamchenkov’s recent post Quick and Easy Introduction into PHP Mess Detector (PHPMD)” as it’s the best instructions I’ve seen for getting PHPMD up and running quickly.

You can also use Sebastian Bergmann’s phploc to calculate Cyclomatic Complexity. (It supports PHP 7.1) To do that, use composer to either require it in your project or require it globally and then from your project’s root directory execute:

phploc ./ --exclude vendor/

Voice First

We’ve all heard of “Mobile First”. Most of us are savvy enough to know that that really means “API First” and then “Mobile is the first client.” Have you heard though, about “Voice First?”

Starting with Siri, but greatly accelerated by the Amazon Echo and now the Echo Dot, we are seeing the birth of a new paradigm for interacting with computers, “Voice.” Ok, so talking to your computer has been around for as long as Science Fiction has, and true enough, in the early 90’s, Dragon Speaking tried to make it happen, but failed. Now though, we have the computing power to not only capture voice, we can quickly send it up the line to computers than can process it, and determine what you said.

Given all of this, it’s probably time you figured out what voice programming is and how it fits in with your current applications. To that end, I’ve got two links for you.

“Alexa, When’s the Bus?” by the always brilliant Lorna Jane Mitchell. Lorna walks you through the basics of creating an “Alexa Skill.” Don’t know what that is? Don’t worry, she explains it. Just go read the post.

And then listen to:

#voiceFirst” by my good friend Phil (Winkle) Jackson. Phil’s podcast Future Commerce is excellent, but in this episode, he starts an interview with Brian Roemmele. They talk about how voice interaction will revolutionize everything.

Don’t miss this bus. Start playing with voice and natural language processing APIs sooner rather than later.