2014年9月29日星期一

Community News: Packagist Latest Releases for 09.29.2014

Recent releases from the Packagist:

Sameer Borate: Creating Twitter Apps in PHP


Sameer Borate has a post today showing how you can create a simple Twitter application in PHP making use of their REST API and the twitter-api-php library.



In this post we will look into accessing Twitter REST API in PHP. This can be useful if you need to post Tweets from your PHP application or anaylze, search Tweets. In the following examples we will use the twitter-api-php PHP wrapper for Twitter v1.1 API. Although there are a few wrappers around, this one I like for its simplicity.


He helps you get the library installed (via Composer) and create an application on the Twitter side at apps.twitter.com. Sample code is included showing how to connect to the API with your credentials, including handling the OAuth authorization piece. From there he shows two examples of action to make on the API: posting a new tweet and searching for new tweets based on a query string.


Link: http://www.codediesel.com/social/creating-twitter-apps-in-php/

Gonzalo Ayuso: Building a Pimple/Container from a YAML file


In a recent post to his site Gonzalo Ayuso shows how to create a Pimple container (a dependency injection container) from a YAML configuration definition using a simple handler already included in Pimple.



[In a conversation with Máximo Cuadros about Dependency Injection Containers] I said that I prefer Symfony´s DIC instead of Pimple, mainly because its configuration with YAML (or even xml) files. But In fact we can customise Pimple/Containers with YAML files in a similar way than we do it with Symfony's DIC. In this example we're going to see one way to do it.


While Pimple does come with the "Container" functionality to make this happen, Gonzalo points out that using it this way violates several of the SOLID design principles. Instead, he offers an alternate solution - using the Config component from Symfony to handle the creation of the container using an already established YAML format. He includes an example YAML configuration structure, the matching Pimple code for it and a code sample showing how the YAML is parsed into the same result. You can find the code on his GitHub account if you're interested in the full structure.


Link: http://gonzalo123.com/2014/09/29/building-a-pimplecontainer-from-a-yaml-file/

Mathias Verraes: Objects as Contracts for Behaviour


Mathias Verraes has a new post to his site today with an interesting idea when it comes to handling the architecture of an application: using objects as the contracts for behavior. He suggests that the objects themselves define how other pieces of code should interact with them, not necessarily external services. He illustrates with an invoice and appointment example.



Of course invoices do not pay themselves, but that's not what an object model is trying to do. An invoice exposes the behaviour of being able to be paid. That ability is in fact essential to what it means to be an invoice. The behaviour is an inherent property of an invoice. If an invoice doesn't have the ability of being paid, there's no point in issuing invoices at all. In other words, the contract of an invoice object declares that its interface includes payment as a feature. Its promise to the outside world is that it allows an outsider to pay for it. Encapsulation of state and behaviour is the core idea behind objects.


He wonders why, if this is more true to the "object-oriented programming" ideals, the idea of encapsulating procedural code as objects is so widespread. He suggests a lack of education on the subject or maybe even confusion from spoken languages themselves.


Link: http://verraes.net/2014/09/objects-as-contracts-for-behaviour/

Mattias Noback: Backwards compatible bundle releases


In his latest post Matthias Noback talks about a problem common to Symfony bundles (and, well, software in general) - dealing with backwards compatibility and breaks that could be introduced with new changes.



With a new bundle release you may want to rename services or parameters, make a service private, change some constructor arguments, change the structure of the bundle configuration, etc. Some of these changes may acually be backwards incompatible changes for the users of that bundle. Luckily, the Symfony DependenyInjection component and Config component both provide you with some options to prevent such backwards compatibility (BC) breaks.


He breaks the post up into a few different kinds of backwards compatibility breaks that could happen and code examples of each:



  • Renaming things
  • Changing visibility
  • Changing values


Each topic also includes methods for preventing issues with older users who maybe aren't using the new features. This includes things like sane default values for new settings, renaming services and creating new extensions for working with new properties.


Link: http://php-and-symfony.matthiasnoback.nl/2014/09/backwards-compatible-bundle-releases/

2014年9月28日星期日

Community News: Packagist Latest Releases for 09.28.2014

Recent releases from the Packagist:

2014年9月27日星期六

Community News: Packagist Latest Releases for 09.27.2014

Recent releases from the Packagist:

2014年9月26日星期五

Site News: Popular Posts for the Week of 09.26.2014

Popular posts from PHPDeveloper.org for the past week:

Community News: Packagist Latest Releases for 09.26.2014

Recent releases from the Packagist:

SitePoint PHP Blog: Essentials of LDAP with PHP


On the SitePoint PHP blog today Matthew Setter has written up a tutorial sharing the essentials of PHP with LDAP. He shows how to connect PHP to this industry standard technology and effectively query, update and delete information.



Ever wanted a simple way to store address book style information and network information actually next to any kind of ordered information? If so, then there's a technology which has been around since 1993, one which despite not having the cool factor of such technologies as Node.js and Go, allows you to do exactly this. It's called LDAP!


He starts off the tutorial by explaining a bit about what LDAP is (and isn't) for those not familiar with it. He covers some of the basic terminology, pointing you other articles if you need more than just his brief overview. Then he helps you get an LDAP server installed locally (using a package manager, apt-get) and how to verify the install is working correctly. From there he shows how to populate a few records and verify they exist. Following this, he gets to the PHP part of things, showing how to use the Zend Framework v2 Zend/Ldap component to access the server, query records and update/delete them easily.


Link: http://www.sitepoint.com/essentials-ldap-php/

SitePoint Web Blog: How Do You Work With Other People's Code?


The SitePoint Web blog has a recent post from Matthew Setter offering some helpful hints on working with other people's code. In it he shares suggestions ranging from the technical out to a bit more "learning oriented" to get up to speed on concepts and techniques.



Dealing with code created by other people is a fundamental skill for a developer. Give it a year and other people's code could even be your own. Today I'm going to look at some of the best approaches for how to deal with other people's code, read legacy code, effectively. It's not an easy topic to cover.


He's broken it down into a list of several different topics, each with their own descriptions and links to tools or reading resources for more information:



  • Interact
  • Observe
  • Run Tests
  • Fix Bugs designed for Newcomers
  • Find Available Resources
  • Use a Good IDE
  • Read Books & Blogs
  • Contribute to Documentation
  • Be Considerate


He puts some good emphasis on that final point, reminding the reader that it's not just years of experience that make for a better developer, it's more about skill.


Link: http://www.sitepoint.com/work-peoples-code/

Matthieu Napoli: Decoupling packages


In a recent post to his site Matthieu Napoli looks at some first steps you can take to help decouple packages in your application. He describes a few considerations and methods to think about as you try to break those chains.




Decoupling packages is a hard thing. There are not a lot of options, and this blog post is about how some options are better than others.



Let's say for example that you are writing a "package", or library, to respond to HTTP requests (that kind of package could be considered the basis for a web framework). How do you handle routing? If you write your Router package as an independent package (which is good: small and specialized packages are more reusable and maintainable), you might not want to couple the HTTP package to the Router package: you want to leave users free to choose the router of their choice. So, what are your options to make the HTTP package and the Router package decoupled from each other?




He looks at a few different approaches including focusing on event-driven programming or splitting things along "edges" and making interfaces/adapters to hook them together. He also puts an emphasis on standardizing interfaces, even those outside of your own internal to the application (think the set of PHP PSRs).


Link: http://mnapoli.fr/decoupling-packages/

2014年9月25日星期四

Site News: Blast from the Past - One Year Ago in PHP

Here's what was popular in the PHP community one year ago today:

Community News: Packagist Latest Releases for 09.25.2014

Recent releases from the Packagist: