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

Community News:
PHP-FIG Website Relaunch
Oct 26, 2015 @ 11:27:30

The PHP Framework Interoperability Group (or PHP-FIG for short) has just released a new version of their website with a great new look and even better organization for the PSR content: http://php-fig.org. They just tweeted about it too:

What do you think of our new website? Slicker, cleaner and easier on the eyes. Give us your feedback! :)

The new version of the site provides sections not only for the details around currently accepted standards but also on current proposals, members of the organization, bylaws and frequently asked questions about the group. They also have links to some resources where you can get involved if you're interested in the group and what they're up to.

tagged: phpfig website relaunch interoperability group redesign

Link: http://www.php-fig.org/

Setting the Context in a Laravel Application
Sep 24, 2015 @ 13:39:46

Continuing on their series about context in Laravel applications, the Culttt.com blog has posted the next part talking about setting the context of the application. In this case the term "context" relates to the "operating environment" the request is happening in (not to be confused with the environment, things like the server/software installed).

Last week we looked at managing context in a Laravel application. Context is a very important aspect of a web application as this foundational structure will be relied upon for almost every piece of code. Setting the context usually involves checking against the business rules of the application.

For example, does the current user have access to this group? Does the current task belong to this project? Can this user create a new post in this thread? These kind of foundational business rules need to be addressed whenever a request enters the application.

He starts by talking about the importance of the URL the user is requesting, pointing out that it should be both useful to identify the resource and provide a "sense of hierarchy" for the application. He then shows how to, using the "Guard" handling in Laravel, to define the context and ensure that the user is operating within an allowed context. Full code is included to set up the system and creating the objects to resolve the group and request information into something useful.

tagged: context laravel application tutorial group request guard

Link: http://culttt.com/2015/09/21/setting-the-context-in-a-laravel-application/

Building With the Twitter API: Repeating Tweets From a Group
Jan 19, 2015 @ 11:18:45

NetTuts.com has continued their series about constructing a Twitter application as a Yii framework-based application. In this latest tutorial they expand on the previous post's "tweet storm" functionality and instead posts random updates based on pre-defined content. If you need to catch up, you can find the other parts of the series here.

The nature of the Twitter stream makes repetition useful, within reason; overdoing it is spammy and annoying.[...] This automates the task of repeating and creating variation over time to increase the likelihood that your Twitter followers will engage with your content. Keep in mind that the Twitter API has limits on repetitive content. You'll be more successful if you offer a wide variety of variations and run the service on an account that you also use manually to share other content.

They start with a short list of features the application needs to support including the main goal of posting the randomized, recurring tweets. They start by creating the Group model and table to allow for the grouping of tweets. Then they use Yii's scaffolding to create a form for creating new groups. Next up is the controller code to handle the group submission and an update to link a tweet to a group. Finally they include the code to push the tweets out to Twitter and mark the tweets as sent. The post ends with an example of a timeline with the resulting posts.

tagged: tutorial series twitter api repeat tweets group random

Link: http://code.tutsplus.com/tutorials/building-with-the-twitter-api-repeating-tweets-from-a-group--cms-22490

Jani Hartikainen:
How to make your code self-documenting?
Dec 02, 2014 @ 09:35:21

In this new post to his site Jani Hartikainen suggests a few things you can do to help make your code "self-documenting" and more readable down the line (or for other developers).

Isn’t it fun to find a comment in code that’s completely out of place and useless? What if you could write fewer comments and still keep the code easy to understand? One of the primary ways to do this is making your code-self documenting. When code is self-documenting, it doesn’t need comments to explain what it does or its purpose, which is great for making the code easier to maintain. As a bonus, with fewer comments, it’s less likely they’ll be crap! In this article, I will show you several ways you can make your code document itself.

He breaks it up into a few different sections, each with some code examples and descriptions:

  • Naming things
  • Extract functions
  • Introducing variables
  • Defining class and module interfaces
  • Code grouping

He finishes up with a few smaller tips including "don't use strange tricks" and "use named constants". What do you think makes for good self-documenting code? Share some of your own thoughts on the post.

tagged: selfdocumenting code examples naming separation extract group

Link: http://codeutopia.net/blog/2014/12/01/how-to-make-your-code-self-documenting/

Symfony Blog:
Improving REST in Symfony
Jul 11, 2014 @ 12:15:56

On the Symfony blog there's a recent post about a new effort being started to help improve REST in Symfony-based applications. William Durand talks about some of the current tools and some of the missing features/difficulties each has. This effort wants to help change that.

Building APIs with Symfony is not new. We've done that since the early beginning of Symfony: Askeet, Jobeet, it's been a long time! Nowadays, more and more web applications are made of an API and a client side application. Sharing data across applications using APIs also became an essential feature. [...] For most of us, it is not as clear as it should be, and we can certainly do better than what we have right now! Hence the creation of a working group to gather both people and knowledge for REST in Symfony: https://groups.google.com/forum/#!forum/resting-with-symfony.

The target of the group is just about anyone associated with the development of APIs: developers who build them, developers to contribute to Symfony's REST functionality, people with questions about REST and, really, anyone else interested. It's a part of their wider developer experience initiative they've recently ramped up.

tagged: developer experience rest discussion group symfony framework

Link: http://symfony.com/blog/improving-rest-in-symfony

What is PHP-FIG and What are They Doing?
Jan 22, 2014 @ 12:42:43

You may of heard about the PHP-FIG group but aren't quite sure what they're about or what they've produced so far. In this new post on PHPBuilder.com, they get into some of the details of the group, including descriptions of the currently released PSRs.

If you have been watching the development of PHP over the last few years, you will know all about the problems with the language. The standard story is that PHP is a fragmented language, it is a language for hacks, there is no real specification, and so on and so forth. The reality is that PHP has grown up a lot recently. PHP 5.4 brings the language closer to a complete object model, and supplies a lot of new functionality. So far, so good. But what about frameworks? [...] PHP-FIG is the short name for the PHP Framework Interop Group (am I the only one who finds the naming of PHP groups and libraries after fruits amusing?) and their mission is simple: to find a way to get the PHP frameworks to work together.

They cover some of the members of the group (well, the projects represented) and look at each of the PSRs in detail:

  • PSR-0 - Autoloading Standard
  • PSR-1 - Basic Coding Standard
  • PSR-2 - Coding Style Guide
  • PSR-3 - Logger Interface
  • PSR-4 - Improved Autoloading
tagged: phpfig psr introduction framework interoperability group

Link: http://www.phpbuilder.com/articles/application-architecture/optimization/what-is-php-fig-and-what-are-they-doing.html

Engine Yard:
Improving Your Local Tech Group
Oct 04, 2013 @ 11:28:47

On the Engine Yard blog today PJ Hagerty has a new post sharing some of his suggestions to help improve your local tech-related group and promote growth.

There are hundreds of User Groups across North America and around the world. These groups are primarily socially based or hacker groups who gather regularly to work on group or individual “toy” projects. Most groups will remain small and insular. It’s easy to stick with what is familiar and keep recycling the same format every month. Unfortunately, this leads to stagnation and apathy by group members. People will eventually stop showing up and the group will either suffer along or just cease to exist.

He suggests things that are easier when there's more than one person involved in making it a success - things like "diversify responsibilities" and having a "coordinator for outside the group activities", but they're helpful tips. He also points out a few other things to remember - that communication with the group is key, "thinking globally" to get your group involved outside the local scope and getting sponsors involved.

tagged: suggestion improve technology group communication

Link: https://blog.engineyard.com/2013/improving-your-local-tech-group

Nomad PHP:
November 2013 - Ed Finkler, "More Code, More Problems"
Aug 30, 2013 @ 10:38:38

The Nomad PHP (virtual) user group has announced their speaker for the November 2013 meeting - Ed Finkler talking about the problems that come with having "more code" in your applications.

In this talk I’ll extend the concepts to other languages we work with in web development, establishing these core principles: Learn languages, not frameworks, build small things, less code is better than more, and create and use simple, readable code We’ll cover how following these principles makes you a better developer, and makes the job of maintaining and verifying your code much easier.

The meeting is on November 14th and you'll have to sign up if you'd like to attend. There's a $10 USD cost for a ticket and you can purchase them right up until the event.

tagged: edfinkler nomadphp november virtual user group

Link: http://nomadphp.com/2013/08/29/november-2013/

Is there anything wrong with using functions?
Aug 07, 2013 @ 11:39:47

In a largely object-oriented world, one Redditer asks if it's still okay to just use functions, the more procedural method of PHP development:

Is there anything wrong with using an include file of functions instead of using full code in a file? [...] Obviously you wouldn't write functions for one off tiny things, but I think it would help to read files altogether especially if the functions file was alphabetically listed.

There's several suggestions in the comments including things like:

  • You should also look into using a templating engine, so you can separate your html from your php code.
  • One thing you could always ask yourself is "Do I will ever need to write that part a second time somewhere else ?" If "yes", that means you should put that part in a function.
  • Before you go writing a load of functions and putting them all in a file, which can get quite unmanageable, consider grouping them logically and placing them in classes.
  • Function names should start with a verb though (except for trivial getters whose meaning is clear by context, which can be named after the thing they get).
  • Do group them logically, but it's not necessary to place them in a class unless they share data or state.
tagged: oop functions procedural opinion file group

Link: http://www.reddit.com/r/PHP/comments/1jss6q/is_there_anything_wrong_with_using_functions

Matthew Weier O'Phinney:
Feb 28, 2013 @ 10:45:20

Matthew Weier O'Phinney has a new post to his site today covering the reasons he left the PHP-FIG, the PHP Framework Interoperability Group that was designed to help unify the framework (and PHP) communities with common goals and structure. He talks some about his reasons for leaving and what he hopes the group will, eventually, become.

I had high hopes for the group. It was the culmination of something I've been ruminating on for almost a decade (see post number 12 on my blog, dated to January 2004, for proof). My thoughts have mainly been around coding standards and best practices, helping educate developers around their benefits, and how to leverage both in order to create maintainable code.

He talks about some of the things he sees as shortfalls of the group including the definition of some of the standards (and interface structure), the current thoughts of changing of said standards and some of the "discussion" that happens in the group via the mailing lists and pull requests. He mentions that there were several times that the same discussions would happen all over again, despite people saying it had, and is tired of it.

I have better things to do with my time, things I want to create, software I want to support, hobbies and interests I want to pursue. Debating brace placement, tabs vs spaces (for the umpteenth time), or whether or not annotations have a place in programming in a dynamic language? Not so much.
tagged: phpfig framework interoperability group opinion leaving