2012年7月31日星期二

Community News: Latest PECL Releases for 07.31.2012

Latest PECL Releases:

Matthew Weier O'Phinney: ZF2's New Controller::init()


In his latest post Matthew Weier O'Phinney introduces you to the new init() method in the Zend Framework 2 controllers and how it differs from the one in version 1.



In Zend Framework 1, controller's had an init() method, which was called after the controller was instantiated. The reason for it was to encourage developers not to override the constructor, and thus potentially break some of the functionality (as a number of objects were injected via the constructor). init() was useful for doing additional object initialization. [...] But this feature is missing from ZF2; how can we accomplish this sort of pattern?


In Zend Framework 2, there's no Controller constructor by default anymore, so you have to do things slightly differently. He shows you how to use the event manager to simulate the same thing, attaching an event to the "dispatch" of the controller to do the work. He came back and updated the post with a second method that could do the same thing - using the ServiceManager from inside a module and attaching the event that way.

Anthony Ferrara: Framework Fixation - An Anti Pattern


In a recent post to his blog Anthony Ferrara takes a look at what he calls the "Framework Fixation" anit-pattern - that one of the first inclinations he sees is to use a framework when it may not be needed.



In this day in age, it seems that the community trend is completely and unequivocally trending towards the use of web application frameworks. So much so that the defacto first comment to someone asking how to do something seems to be "Just use a framework, and it'll solve the problem for you." While I completely understand why this is the case, I can't say that I agree with it. And while I do believe that frameworks serve a purpose, I think that they are vastly over-used. Let me explain why...


He starts off by describing what a framework is (its components, goals) and points out a few flaws in their use. These include the removal of emphasis on the setup/configuration/bootstrapping of the application (it's part of the architecture too!), how they can help (and hurt) in prototype situations, the myth of the shorter development time and that looking for "framework developers" that only know how to use the tool could hurt you in the long run.

Thomas Weinart: Using The PHP 5.4 Webserver On Windows


Thomas Weinert has posted a helpful hint for those developing their PHP applications in a Windows environment - how you can use the PHP 5.4 built-in webserver to test your applications.



PHP 5.4 has an built-in webserver. For local development it is not necessary to install Apache Httpd or another webserver anymore. You can just start an server from the command line. [...] To make things a little easier you can create a windows shortcut.


He shows what it looks like running in a console and steps you through the process of setting up the shortcut, giving you the flexibility to contril things like window size and buffer size.

Voices of the ElePHPant Podcast: Interview with Rafael Dohms


The Voices of the ElePHPant podcast has released its latest episode - an interview with Rafael Dohms of the Amsterdam PHP user group.



Cal's three questions for Rafael about his involvement in the community:



  • Tell us about your experience integrating with a whole new community when you moved from Brazil to Amsterdam
  • Talk to us about Amsterdam PHP
  • Talk some about how the leadership of the user group is set up ("enablers")


You can listen to this latest episode either through the in-page player, by downloading the mp3 or by subscribing to their feed.

2012年7月30日星期一

Community News: Latest PEAR Releases for 07.30.2012

Latest PEAR Releases:

DeveloperDrive.com: 6 Ways Web Developers Can Damage Thier Career


In this new post to the Developer Drive site today, they share six things that you, as a developer, can do to hold you back in your career (or development growth in general).



The web development industry is one that is always growing because of how we use the web. No longer do we expect the Internet to simply host a digital pamphlet for a business. The expectations nowadays are for a site to be rich with content, provide the means for visitors to interact and be dynamic in every interaction. With the demand at an all time high, freelance web developers may think that there is little they could do to harm their career. Unfortunately, there are many ways that people in this industry sabotage themselves when it comes to their career.


Among the things they recommend avoiding are practices like clinging to older technologies, failing to network with other developers and market themselves and forgetting why you were hired in the first place.

Nikita Popov: How to add new (syntactic) features to PHP


Nikita Popov has a new post to his site looking at how you can add your own syntactic features directly to PHP (requires knowledge of the C language).



Several people have recently asked me where you should start if you want to add some new (syntactic) feature to PHP. As I'm not aware of any existing tutorials on that matter, I'll try to illustrate the whole process in the following. At the same time this is a general introduction to the workings of the Zend Engine. So upfront: I apologize for this overly long post.


He covers the usual "life" of a PHP script, how tokenization is handled and what happens when the script is parsed, compiled and executed. Code snippets are included to show you the points to add in your own syntax item - in their case, adding an "in" operator to see if a value is in an array (a one word version of this).

Community News: FixThatCode.com Launched


Rafael Dohms has started up a new project that wants to help developers get help on their broken code via collaboration with others - FixThatCode.com.



Coding is an art. There are many ways to paint an apple, but which is better? Most of the code we write everyday can be written in better ways to achieve different objectives. Sometimes all it takes is a fresh pair of eyes. Code quality can be observed through various identifying markers. Perhaps you're not aware of them, don't have time to look for them or are too caught up in the moment to notice? That's where FixThatCode.com steps in!


There's a few different categories you can ask for help in including "Make this code better", "Make this code faster" and "Give me feedback". So far there's some interesting examples to look at - mostly in the "Feedback" category as developers look to further their skills by learning from others. The site's still just starting out, but I could see it becoming a good resource to any community - not just PHP!

TrueLogic.org: Integrate the Mailchimp API with your PHP application


In this new tutorial to the TrueLogic.org site, they show you how to use the Mailchimp (using a library) from your application.



For those unfamiliar with Mailchimp it is an online service for handling subscribers and newsletters. It is mainly used to handle subscription lists and sending newsletters via its Mailchimp API which has wrappers and integration features for various languages/platforms. [...] In this article we will take a quick look at how to integrate this with your PHP application. If you want a detailed reference on integration then its better to look at the official API documentation. Here, we just want to give a simple and practical explanation on how to go about it.


Once you've gotten an API key, you can follow along with the tutorial. They show you how to subscribe to lists, create campaigns, unsubscribe from a list and delete a campaign.

2012年7月27日星期五

Site News: Popular Posts for the Week of 07.27.2012

Popular posts from PHPDeveloper.org for the past week:

Symfony Blog: The Symfony Community Survey 2012: The Results


On the Symfony Blog there's a new post sharing the results of a recent poll they took of some of their developers covering things like job title, how long they've been working with Symfony and their work with the framework.



Before the Symfony Live Conference in Paris, we conducted the first Symfony community survey. The raffle winners will soon be contacted by Anne-Sophie. And without further ado, here are the survey results!

Results are posted both in numbers and in easy to read graphs to questions like:



  • What is your job?
  • How did you get to know symfony?
  • Do you use any other PHP framework/CMS?
  • What is the average size of projects that you/your company work on?
  • How do you get trained?


The last question is interesting - it asked the community how many would be interested in getting a Symfony certification. The results were almost broken into equal thirds of "yes", "no" and "somewhat interested. You can see the full results here.

Tim's Blog: Cyclic Dependency Injection and Making a Choice


In this recent post Tim shares a time when he came across a case of "cyclic dependency injection" and how he handled it.



Cyclic dependency injection is your code asking you to make a choice rather than remain on the fence. Here's a story of what happened in my case. I ran across a troubling case of cyclic dependency injection in the constructors of some code.


In his example, one object takes in another injected as a parameter to a method. The second object then takes in an instance of the first object as a parameter to one of its methods, the circular dependency. He shares both the original code that was performing this dependency issue as well as the refactored code showing his solution (hint: moving functionality around can be a good thing).

Reddit.com: I'm interested in teaching others PHP. Is anyone interested?


If you've been doing PHP for a while and feel the need to get out there and help others learn the language (and the whole ecosystem around it) but don't know where to start, check out this thread over on Reddit with some helpful resources and suggestions.



I'm interested in teaching PHP and programming concepts to people. I've been told that I teach people in a way that is easier to grasp than what's conventional and I would like to get other peoples opinions on how to produce code and perspectives when you're not native to PHP specifically.

In the comments there's mentions of things like:



  • the PHP Mentoring project
  • ProTalk.me for sharing your videos
  • What kinds of topics people are looking for
  • and responses from people that would like to learn more about the language themselves

PHPMaster.com: Writing a RESTful Web Service with Slim


On PHPMaster.com today there's a new tutorial showing you how to create a simple RESTful API with the help of the Slim PHP microframework.



Through a series of articles here at PHPMaster you've learned about what is REST and how it works. In this article, I'd like to show you how to create a RESTful web service using Slim, a PHP micro-framework inspired by Sinatra, a Ruby framework. It's well-suited for creating simple RESTful web services and comes with some minimal components like Router, Request, Response, and View. It's very simple, and is easy to understand and use.


He walks you through the basics of getting the framework downloaded and set up as well as showing you how to make some basic routes ("Hello World" style). He then uses the NotORM library to work with his database and, via a RESTful interface, give information about books, edit their information and add new ones.

2012年7月26日星期四

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

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

PHPMaster.com: Baking Cookies in PHP


On PHPMaster.com there's a new tutorial about working with cookies in PHP applications - an introductory look at what they are, how to set them and how to read their values.



Have you ever wondered that in spite of HTTP being a stateless protocol, when you log in to a website and buy stuff and checkout how the server can identify you uniquely? You might wonder if HTTP is stateless but your state is maintained through your interactions, isn't this a contradiction? Welcome to world of cookies (not the ones which we can eat, btw :)), one the of primary ways to maintain user state and interaction between the web browser and the web server.


She shares a lifecycle of a common cookie and describes the parts of the setcookie method (parameters). There's also a few code examples showing how to read and write to them as well as update their values/expirations.

Script-Tutorials.com: Google API - Get contact list


In this new tutorial on the Script-Tutorials.com site, they show you how to use the Google API (and OAuth) to access contacts information from your Gmail account.



In our new tutorial I am going to tell you about inviting friends. I think that this is the most important part for every website, a key to success. Today I will show you how to create simple and effective Gmail contact importer using OAuth authorization and API. Also, I will tell about obtaining Google API access too.


Screenshots show you how to get to the access token information you'll need to connect and the full code is included to help you get authenticated and pull down the contacts list to display in the page's HTML output.

/Dev/Hell Podcast: Episode 17: This Show Is Terrible


The latest episode of the /Dev/Hell Podcast has been released - Episode #17, "This Show Is Terrible" hosted by PHP community members Ed Finkler and Chris Hartjes.



This week on /dev/hell we talk about mentoring. Chris discusses his experiences taking a young up-and-comer under his wing, and we talk about the PHP Mentoring project. Then we babble about Aspen, an interesting, non-traditional Python web framework. Good and bad stuff in PHP gets knocked around again. Finally, Ed talks about fixing his dryer and yells at the audience.


You can listen to this latest episode in a few different ways - either through the in-page player, by downloading the mp3 or by subscribing to their feed.

2012年7月25日星期三

Community News: Latest Releases from PHPClasses.org

Stefan Koopmanschap: Data migration with Doctrine2


In this latest post to his site Stefan Koopmanschap shares a solution he's found to migrating data with Doctrine2 from an existing structure.



A project that I'm working on right now required me to migrate data from the existing database to the new database and database structure. Since the application is built on top of Symfony2, I decided to write a Command that would take care of the migration. I ran into an issue though: Doctrine2 insisted on creating new IDs where I wanted to keep the old one. The solution turned out to be really simple.


The actual code for the Command is only a few lines long - it just turns off the "AUTO" strategy for each of your entities, making it ignore any IDs you have set on the entity already.

Community News: PHP Benchmarks Compared to Several Languages


Ariz Jacinto has pointed out some results from a recent benchmarking "game" that compares the performance of several languages against each other in overall speed.



Here's the link to the Computer Language Benchmark Game as of July
15, 2012. You'll see that the median speed of PHP is slightly faster
than Python 3 and Ruby 1.9 on x64 Ubuntu/IntelQ6600 Quad-core machine.


You can visit the results page and turn on and off various languages to get the updated results in the chart. You can also limit it down to one of the many benchmarking test types as well.

BinaryTides.com: Javascript style object literals in PHP


On the BinaryTides.com site there's a recent post for those familiar with Javascript and wanting to have the same kind of object-style literals in PHP.



As similar thing [to Javascript object literals] can be done in PHP using anonymous functions (since 5.3) [...] Since version 5.3 Php added support for closures and that feature has been used above to create javascript style object literals. The use(&$a) expression makes the variable $a available inside the function happy.


Code snippets are included showing how to create these objects via the use of closures and a little trickery with call_user_func_array and __call to make assigning properties easier.

2012年7月24日星期二

Community News: Latest PECL Releases for 07.24.2012

Latest PECL Releases:

Anthony Ferrara: What Generators Can Do For You


Anthony Ferarra has a new post looking at using generators in your code (as proposed here). He introduces the idea behind them and shows both a simple and more complex example of their use.



The concept of generators was recently proposed for addition in PHP's core (Possibly for 5.5.0). While I believe that this is a great tool, it appears that many PHP developers aren't familiar with the concept of generators. So I thought I would take a little time and explain some of how it works, and how it can be used to greatly simplify code.


He explains the concept of "generators" as an easier way to implement iterators. In his example he shows how to refactor is file handling iterator to replace it with generator functionality. It uses a new keyword, "yield", to return a Generator instance that can then can be used much like the file iterator without the need for all of the code to create the iterator itself. His more complex example shows how to replace an ArrayObject instance by a little trick inside its "getIterator" method.

PHPMaster.com: Using YAML in Your PHP Projects


On PHPMaster.com today there's a new tutorial showing you how you can use YAML documents on your applications ("YAML Ain't Markup Language") for configuration files.



Test fixtures, configuration files, and log files all need to be both human and machine readable. YAML (YAML Ain't Markup Language) is a less-verbose data serialization format than XML and has become a popular format among software developers mainly because it is human-readable. YAML files are simply text files that contain data written according to YAML syntax rules and usually have a .yml file extension. In this article, you will learn the basics of YAML and how you can integrate a PHP YAML parser into your projects.


They start with a brief introduction to the YAML syntax by comparing them to the structure of a typical PHP array. They include the YAML output from these examples and how, despite the ease of its use, it shouldn't be considered a replacement for something like XML (they both have their strengths). He points out some of the current YAML parsing libraries and how to integrate them into your app (he uses the Symfony option).

DZone.com: Refactoring away from spaghetti PHP


In this new post to DZone.com, Giorgio Sironi walks you through a few steps to consider when trying to refactor some of the spaghetti code out of your application.



Sometimes you have to take a step back from discussions on coupling, cohesion, patterns and katas to give some training to the ones of us that have a procedural mindset. With this article I hope to provide some initial tips for the members of the PHP community that are ready to abandon the concept of the OneSingleProcedure(TM) to embrace the object world.


He includes a common procedural example with all of the logic in one file and talks about how the idea of "decomposition" can help to break it up into objects with their own roles and responsibilities.

2012年7月23日星期一

MaltBlue.com: Why Kohana is an Excellent Alternative to Zend Framework


On MaltBlue.com today Matt has a new article posted describing why he thinks Kohana is a good alternative to the Zend Framework in some projects.



recently I've been doing a lot of research in to some of the best PHP frameworks and codebases, including Symfony 1 & Symfony 2, Drupal, CakePHP and Kohana for a technical documentation project that I've been working on. [...] Well, to say the least, I was really surprised at just how simple, lightweight and easy Kohana is to use. Wow, what a true breath of fresh air it is after using Zend Framework for so long now.


He talks some about the things he likes about the framework (including a well-structured configuration file and its overall speed) and includes a simple "getting started" tutorial. He shows you how to make a simple application that includes database support, caching and the MVC stack to display a list of users.

EngineYard.com: Chicks that Rip: Elizabeth Smith


In the newest post in their "Chicks that Rip" series of podcasts spotlighting women in technology, Elizabeth Naramore interviews Elizabeth Smith, a member of the PHP community about her involvement in a few different projects (and her work).



[In this episode] Elizabeth Naramore interviews Elizabeth Smith of mojoLive about working on PHP for Windows and starting phpmentoring.org


They talk about her move from dance to programming, the work she does on PHP and Windows, issues she sees in the PHP core code, the PHP Mentoring project and some of her own advice for working moms. She also mentions the CoApp, an open source package manager for Windows.

Reddit.com: An interesting negative take on Dependency Injection


In this recent post to Reddit.com there's some commentary about an older article sharing a negative spin on dependency injection and how it could cause more trouble that it's worth.



The attitude of these pattern junkies doesn't work with me. *I* will decide whether or not I will use a particular design pattern, and *I* will decide how I implement it. This usually means that I don't use design patterns at all, and those that I do use are implemented in my own unique way. Because of this I am widely regarded as a maverick, a heretic and an outcast by those who consider themselves to be "proper" OO programmers.


Comments in the Reddit post talk about DI not being a "silver bullet", how it "empowers polymorphism" and how design patterns should not be done for the same of using design patterns

Matt Cockayne: Bootstrapping ZF2 Forms


In this recent post to his site, Matt Cockayne shows you how to bootstrap your forms in a Zend Framework 2 application (as defined in a class).



A brand spanking new Forms component has been rolled out with ZF2. The long and the short of this new component meant that I had the opportunity to hand roll a new way of making my forms work with Twitter Bootstrap. So, a little tinkering, a quick pull request to ZF2 to allow the definition of arbitrary options and I came up with some useful View Helpers that can be dropped into a project and used.


He includes the code for the sample class ("MyForm") and highlights the "bootstrap" portions of each element's configuration and walks you through some other handy features of his helpers: auto-rendering forms, a "row" helper and a "collection" helper to help organize the form structure.

2012年7月20日星期五

PHP.net: PHP 5.4.5 and PHP 5.3.15 released!


The PHP project has just released the latest versions of the language - PHP 5.3.15 and PHP 5.4.5 - with the major of updates being security and bugfix related.



The PHP development team would like to announce the immediate availability of PHP 5.4.5 and PHP 5.3.15. This release fixes over 30 bugs and includes a fix for a security related overflow issue in the stream implementation. All users of PHP are encouraged to upgrade to PHP 5.4.5 or PHP 5.3.15. For source downloads of PHP 5.4.5 and PHP 5.3.15 please visit our downloads page, Windows binaries can be found on windows.php.net/download/. The list of changes are recorded in the ChangeLog.


Fixes include updates related to problems in the FPM, Iconv, JSON, libxml, Phar and Zip extensions. You can find the links to these and other bugs in the Changelog.

Site News: Popular Posts for the Week of 07.20.2012

Popular posts from PHPDeveloper.org for the past week:

Evan Coury: Introduction to the Zend Framework 2 ServiceManager


Evan Coury has posted a quick guide to one of the major features of the Zend Framework 2 project so far - the ServiceManager. He introduces the component and talks about some of its key features.



So, what is the ServiceManager? Basically it's a registry, or container (the proper term is service locator) to hold various objects needed by your application, allowing you to easily practice Inversion of Control. The service manager holds just the information needed to lazily instantiate these objects as they're needed. So if you were thinking 'services' such as those composing a service layer, you might be better off thinking of the service manager more as an "object manager" or "instance manager".


He mentons some of the functionality that comes with the component including invokables, factories, aliases, initializers, configuration classes and abstract factories. He also links to the ServiceManager quickstart over in the Zend Framework 2 documentation for more information.

Marco Tabini: Duck blinds


In this new post Marco Tabini gives his take on "language haters" and how it's less about the language and more about what you do with it.



The reason why I'm here is that, on occasion, a person decides that it's time write Yet Another PHP Bashing Post. Typically, this is followed by a bunch of Posts Defending PHP. [...] Saying that PHP is horrible or great is no more useful than saying that a hammer is horrible or great (regardless of the number of claws it comes with). [...] The real question is whether PHP - or any other technology - is good for you.


He goes on to mention current successful projects that use PHP, but focuses on the people and the ideas that made them happen, not the language "behind the scenes". He also comments on what he thinks makes a good programmer (and one that has matured past the "X language is the best!" stance):



And this brings me to the crux of the matter: The trick to being a great programmer is to learn as much as you can about as many programming languages and techniques as you can. Eventually, you'll learn that any language is excellent at some things, good at others, and a poor choice for many others. It's all about the context, and finding the right tool for the job.

Engine Yard: Introducing Lithium: The simple, fast and flexible PHP framework


For those that have heard about the Lithium PHP framework but haven't gotten a chance to get into it, Engine Yard is hosting a webinar just for you. Nate Abele, one of the core developers for the framework, will be presenting an introduction to the framework on July 26th.



Lithium is a framework for PHP 5.3+ that is focused on quality, speed, and flexibility. It's a set of no-nonsense philosophies and tools that enable you to build better applications, in less time, without sacrificing quality or extensibility. Lithium understands distributed storage and caching, queuing systems, micro-dispatch frameworks, with integrated support for document oriented databases like CouchDB and MongoDB, alongside relational databases like MySQL and PostgreSQL. Lithium's architecture allows you to get your application up and running quickly, and still allows you to take control of the framework to support the requirements of your application.


If you're interested, you can sign up for the webcast on the Engine Yard site. The event happens July 26th at 10am PST.

2012年7月19日星期四

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

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

PHPMaster.com: Database Interaction Made Easy with NotORM


On PHPMaster.com today there's a new tutorial showing you how to use the NotORM tool to work with your database:



Object Relational Mappers (ORMs) are cool. They help you to rapidly create your application without worrying about writing raw SQL queries. The idea is to simplify database interaction and avoid possible errors in writing complex queries. In fact, modern ORMs can generate Models/Entities from the database, and vise versa. But the reality of working with any ORM is that using it is only simple if you already have experience using it. To make the most out of it, you should have a deep understanding of the concepts. And there's a steep learning curve associated with any ORM.


They introduce you to the NotORM tool and guide you through some of the initial steps to help make this curve a little less steep. Their sample database contains book information (author, category, book detail, etc) with PDO making the connection (injected into the NotORM instance). They show how to do things like simple selects, filtering with "where", sort the results, doing joins and doing inserts.

Lorna Mitchell: PHP 5.4 Benchmarks


In this quick post to her site, Lorna Mitchell shares some of the benchmark results she found when doing some tests with the latest version of PHP - 5.4.



Today I'm giving my first ever talk at OSCON - about PHP 5.4 (I'll also be giving my second ever talk at OSCON, about RESTful services; it's a busy day!). My talk includes some benchmarks which I thought I'd also share here. [...] This graph shows the performance of four versions of PHP (because the bench.php script that lives in the php source tree didn't appear until 5.1). The axis up the left is the time it took to run the benchmark script - so a smaller number is better news.


You can see a dramatic difference between even just the latest in the PHP 5.3.x series in the 5.4 results. There's also a table with the details of each of her 10 executions of the "bench.php" script showing the results of the time spent to run the script on four different PHP versions.

Anthony Ferrara: The Anatomy Of Equals - Opcode Analysis


Anthony Ferrara has a new post today getting into the details of how "equals" works in PHP at the opcode level. He focuses on the answer to a question he received:



I was asked an interesting question via email yesterday. The question is fairly simple. The answer, not so much... So, rather than reply in an email, I figured that I'd write a post about it instead. The question, simply stated, is: "When comparing a float to an integer using ==, where does the conversion happen?"


He starts with a super simple piece of test code that compares an integer (1) to a float (1.0) and walks through the process PHP takes to perform the comparison (with a double equals "=="). He talks about opcode handlers, the "fast equal function" and how it handles the casting from one type to another, C source highlights included.

2012年7月18日星期三

Community News: Latest Releases from PHPClasses.org

PHPEasy.co.uk: Sorting array data using SplMaxHeap


On PHPEasy.co.uk today there's a new tutorial posted showing you how to sort using the SplMaxHeap functionality provided by the Standard PHP Library.



The SplMaxHeap class basically stores numbers in any order, and then returns them in descending order. In order to make this class useful for other data types other than numbers I have extend the SplMaxHeap class to compare dates and strings. SplMaxHeap extends SplHeap and implements the abstract class SplHeap::compare. Our extention of SplMaxHeap is therefore expected to implement the compare method.


Code examples are given showing sorting by things like "last name" and "date of birth" (using strtotime). There's also an example of its use in sorting values from an array and outputted in a loop. You can find out more about this functionality in the PHP manual.

PHPMaster.com: PHPMaster Security Roundup


Security has become more of a hot topic in the PHP community recently and PHPMaster.com has pulled together a list of resources you can read up on to get some great ideas for securing your application.



The unfortunate truth of the matter is there's no excuse for [the LinkedIn, Yahoo!, eHarmony and Last.fm] leaks; they would not have been possible if simple, well-known security precautions were taken. Are you protecting yourself and your applications by guarding against SQL-injection attacks? Are you filtering and validating user input? Are you properly hashing user passwords? I hope so! If not, read some of the security-focused articles PHPMaster has published throughout the past year and apply these best practices to your code today!

Articles in their list include:




Check out the rest of the post for links to other great articles.

NetTuts.com: The Essentials of Creating Laravel Bundles


Continuing in their series looking at using the Laravel PHP framework, NetTuts.com has posted this latest article focusing on the creation of "bundles" for use in Laravel-based applications.



The Laravel PHP framework offers its bundles system to allow developers to redistribute useful packages of code, or to organize applications into several "bundles" of smaller applications. In this tutorial, we will learn the ins and outs of creating and distributing bundles from scratch. A Laravel bundle has access to all of the features that the framework offers to its host application, including routing, migrations, tests, views and numerous other useful features.


They start with the "when to create a bundle?" question, a combination of the answers to four other questions (like "could others use it?" or "should this just be a library?"). From there they get into the actual code, showing you how to create a basic bundle that works with the Gravatar service to pull an image for a given email address. Also included is a sample unit test, how to implement it in the controller and a sample view that interacts with it to make it all work.

2012年7月17日星期二

Community News: Latest PECL Releases for 07.17.2012

Latest PECL Releases:

PHPMaster.com: Implement Two-Way SMS with PHP


PHPMaster.com has an interesting new article posted today showing how you can use PHP to create a two-way messaging (SMS) application that can both send and initiate actions based on message content.



SMS is used for various purposes these days. For example, major websites like Gmail and Facebook use SMS to improve their authentication process with multi-factor authentication and notifying users about the updates. These are one-way SMS applications since messages are sent only from these sites to the user. Two-way SMS applications are more complex than one-way ones. In two-way SMS apps, a user can initiate a conversation by sending messages, and then the application responds according to the user's commands.


They base the application on the Clickatell SMS service (not free, but cheap - pay by the message too) which includes the ability to hook into your API on a specific endpoint and relay the message data. The message can either be sent via a POST or GET and can easily be interpreted in your app extracting things like a timestamp, the number it came from and, of course, the actual text of the message. There's also a section about the "User Data Header" functionality that lets you easily split up a message for recombination on the remote device. Code is included for all examples.

ServerGrove Blog: ServerGrove's PHP Education Initiative


ServerGrove has made an announcement on their blog today about an initiative they're starting to help in their own way to improve the PHP training ecosystem across the community - their "PHP Education Initiative".



PHP Training is an integral part of our PHP community and there are a lot of folks providing great training services making the PHP community safer and stronger. ServerGrove has long supported PHP education by sponsoring PHP User Groups and PHP Conferences, but we realised we have overlooked professional trainers. That is why we are pleased to announce our PHP Education Initiative.


Their part in the project is to provide resources (individual VPSes) for each of the individuals involved to give them a solid platform to work from. It's available to students, educator or user group leader involved in a PHP-centric training session. For more information on getting access to this resource, check out the post for contact information and what will be included.

NetTuts.com: Test-Driven Development in PHP: First Steps


On NetTuts.com there's a new tutorial that wants to help you get started with a different sort of testing methodology than you might not have tried before - test driven development:



Let's admit it: the PHP community has lagged a bit, when it comes to advocating test-driven development. We know we should, but, even to this day, a sizable portion of the community does not. In this new series of videos and tutorials, created by the Nettuts+ team, we're hoping to change that. Trust me: it's not as tough as you think.


This first post in their series helps you get the environment set up (including Composer and PHPUnit) and test a basic class. It's a video, but there's links to the software you'll need to install at the end of the post.

Aura Framework Blog: Contributing to Aura Project


The Aura Framework project has made a new post to their blog walking you through the steps you'll need to contribute back to the project with your ideas and bugfixes for their various components.



Sometimes you may have noticed a bug, or need a feature implemented, and need to contribute back to the aura community. These are some of the steps to help / contribute to aura project.


They walk you through: setting up git (well, point you to github's guide), fork the main repository and check out a copy, creating a remote to the "upstream" (main) repository and pulling the latest content from it into your fork. Included are the commands to run PHP_CodeSniffer and PHPUnit with the provided tests. From there, it's up to you and your code to contribute back, commit and make a pull request!

2012年7月16日星期一

Community News: Latest PEAR Releases for 07.16.2012

Latest PEAR Releases:

Bob Madjak's Blog: Making images transparent using Imagick - enter the pixel iterator


In this recent post to his blog Bob Madjak looks at how to use the Imagick functionality to create images with transparent backgrounds.



So we have this image, and we want to set it to be 75% transparent using Imagick. This sounds simple enough, doesn't it? Perhaps we are trying to create a watermark, or we just want to fade the image for some reason.


He shows how to use the ImagickPixelIterator to take care of some of the issues that can be caused by just a call to "setImageOpacity". A code sample is included in the post showing how to take a source image and make it transparent without ending up with a white border/black background like the other version.

Chris Hartjes' Blog: Monkey-patching Is for Closers


In this new post to his blog Chris Hartjes looks at why "monkey patching is for closers" - how it should be avoided in favor of making the code itself more testable rather than "hack" with the patching.



The use of monkey-patching is extremely prevalent in the Ruby community and also to a certain extent in Python usage. I'm not going to go into length about their use of it except to say that it seems quite common and I think most developers are using it as a shortcut to counter what might be poor code architecture decisions.


He includes some example code, excerpted from a blogging system where runkit was originally use to test its functionally. He shows how some simple refactoring (adding input parameters, replacing a static method call, etc) makes it easier to unit test. Comments to the post include further refactoring ideas as well as a response from the original "offender" whose post sparked Chris' response.

PHPEasy.co.uk: Design Patterns - The Singleton Pattern


PHPEasy.co.uk has a new tutorial posted introducing one of the most common (and often misused) design patterns out there - the Singleton pattern.



In this first tutorial in the design pattern series we are going to investigate and implement the singleton design pattern. [...] A design pattern is a common solution to a given problem, problems in programming tend to recur and we often find ourselves trying to solve the same issues over and over. The common techniques that provide solutions to these problems can be referred to as design patterns.


He talks about some of the most common uses for the Singleton pattern (mainly replacing a global variable) and includes an example of using one to fetch a database object.

2012年7月13日星期五

Site News: Popular Posts for the Week of 07.13.2012

Popular posts from PHPDeveloper.org for the past week:

Derick Rethans' Blog: What is PHP doing?


Derick Rethans has a new post to his blog showing how you can, using a few simple unix tools, figure out what PHP is doing when your scripts are executing.



Sometimes when you have a long running PHP script, you might wonder what the hell it is doing at the moment. There are a few tools that can help you to find out, without having to stop the script. Some of these work only on Linux.


He shows you how to use the following commands to track down exactly what your process is working on: strace, ltrace and gdb (a handy debugger that will probably give you more information than you're looking for). He includes some sample output for the commands and gives an example of a PHP script-to-gdb output relationship.

Reddit.com: History Lesson: What PHP coding was like in 1996


On Reddit.com there's a new post that throws you back to a different time in PHP's life - back to 1996 when PHP was still in version 3:



I was lurking one day on Usenet Perl forums when I saw an announcement about the release of PHP 2.0/FI, the first truly public version of PHP. I was growing weary of trying to get PERL working via CGI and fell in love immediately with how simple and fault-tolerant mod_php with Apache was compared to CGI hell. In 1996, they didn't have sites like reddit when I was a noob. They didn't even have Google when I first learned PHP (years before google existed). Hell! php.net's search functionality barely worked. I don't remember there be any real documentation until after PHP 4 came out in mid-2000.


Other people have added their own memories to the post, mentioning how they started out with the language and some opinions on its current state.

Community News: Atlanta PHP & Atlanta MongoDB Host Derick Rethans


The Atlanta PHP User Group has a special announcement posted to their site - a joint event happening with the Atlanta area MongoDB user group with Derick Rethans (of 10gen) as the speaker.



MongoDB is a scalable, high-performance, open source, document-oriented NoSQL database. [...] This talk introduces MongoDB for developers who aren't familiar with it with a detailed introduction of how to work with MongoDB from PHP. This talk will cover the basics from installing the PHP driver and connecting to MongoDB to creating, inserting, querying for, and updating documents. Schema design will also be covered. This won't be a duplication of the previous MongoDB presentation we had earlier this year.


The event is happening Friday, September 21st from 7-9pm (note that it's September, not this month). More details on the event are to come, so if you're a PHP (or MongoDB) developer in the Atlanta area, stay tuned for the latest info.

2012年7月12日星期四

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: PHPEasy.co.uk Launched

Carl Gresswell has put together a new site that aims to provided tutorials for budding PHP developers out there looking to advance their knowledge of the language and some of the best practices surrounding it - PHPEasy.co.uk.



I have created PHPeasy with the aim of providing tutorials, tips, code snippets and news on the subject of PHP. I rarely get the opportunity to discuss PHP and share thoughts with other like minded developers, so I'm hoping that this blog will allow me to do that. I aim to provide resources that will be useful to coders of all levels, whether a newbie or master I'm hoping that there will be something for everyone.


It's a relatively new site, but there's already a series posted (parts 1-3) about some of the basics of working with object-oriented programming in PHP:


MaltBlue.com: Zend Framework - How To Implement RSS Feeds the Easy Way


On the MaltBlue blog Matt Setter has a new tutorial posted about creating RSS feeds quickly and easily with the help of the Zend Framework and context switching.



Ever wanted to know how to take an existing Zend Framework application where you have posts, records, news or anything else stored in a data source and updated regularly, and make it available as a feed for your users that they can subscribe to? Well today, that's what I want to show you. Recently, during the development of the burgeoning PHP cloud development casts site, I had just that situation.


He shows you how to set up some of the routing for the RSS and Atom feeds, pointing them to specific module/controller/action paths for handling. He then creates a "_getFeed()" method that pulls together the needed content and uses the Zend_Feed_Writer_Feed component to create the feed of the correct type. This is then exported, returned and - thanks to a bit more configuration - turned into a correctly-formatted feed.

PHPMaster.com: Better Understanding PHP's Garbage Collection


If you've been working with PHP for any length of time, you probably have wondered what happens to everything you've created when your script's execution ends. Well, in this new post from PHPMaster.com PHP's garbage handling functionality.



It's interesting how just a few years can make a difference in the names that are given to things. If this were to come up today, it would probably be called PHP Recycling Options, because rather than picking things up and throwing them into a landfill where they'll never be seen again, we are really talking about grabbing things whose use has passed and setting them up to be useful again. But, recycling wasn't le petit Cherie of society back when the idea was developed and so this task was given the vulgar name of 'Garbage Collection'. What can we do but follow what history and common usage have given us?


They talk about a few different kinds of data that the garbage collection system cleans up including the program-generated information and the three tiered system the languages for cleanup:



  • First Level - End of Scope
  • Second Level - Reference Counting
  • Third Level - Formal Garbage Collection

2012年7月11日星期三

Community News: Latest Releases from PHPClasses.org

Stefan Koopmanschap's Blog: PHPNW12: You should be there, and someone can be there


Stefan Koopmanschap, a speaker at the upcoming PHP North West Conference (in Manchester, UK the first part of October) is doing something interesting with a ticket he purchased - he's giving it back to the community and is taking nominations for the recipients.



It all started last year: I decided I wanted to go to PHPNW even if I wasn't accepted as a speaker. Being Dutch, I made sure to purchase my ticket for the conference during the blind bird period to save some money. But then I got accepted as a speaker. Part of the speaker package is a ticket to the conference, so I had this spare ticket. One option would be to get a refund. The PHPNW crew had no problem with this. But then I figured I could actually also try and do some good for the PHP community with the ticket. I'd spent the money already, why not use it for someone's benefit.


He wants to try to provide the same kind of experience and community interaction he did when he first got started with the language, so he's donating his ticket to PHPNW back to the cause. If there's someone you'd like to nominate for is ticket, send an email with their name, contact info and why you think they should be selected over to phpnw12@ingewikkeld.net. He'll select a winner on August 15th so they'll have plenty of time to make arrangements for travel and accommodations.

Phil Sturgeon's Blog: PHP: Ecosystem Update


In this new post Phil Sturgeon looks at two movements in the PHP community that are doing positive things for the language and the community as a whole - the Framework Interoperability Group (PHP-FIG) and the more recent "PHP The Right Way" initiative.



Don't worry guys, this isn't another PHP apologist or PHP hater blog. We've all had enough of those recently. This is a quick heads up on two projects that are doing what they can to make the PHP ecosystem a better place.


He talks a bit about some of the recent work that the PHP-FIG has done, the new standards that were approved by the group (PSR-1 & PSR-2) as well as the launch of a dedicated website for the project, complete with a handy FAQ. He also points out the PHP The Right Way site and the loads of community contributions that have come in around it. There's guidelines for things like dependency management, security, testing, deployment and lots more. If you haven't gotten a chance to check out this resource, it's definitely work a look!

Tom Oram's Blog: Unit testing a Zend Framework 2 Controller


In this recent post Tom Oram looks at a method he's put together for unit testing a controller in a Zend Framework v2-based application (using PHPUnit).



So far I've got a basic Zend Framework 2 Application up and running and got PHPUnit running & testing one of my models. Next up I wanted to try and workout how to test a controller. I had come to the conclusion that what I needed to do was create an instance of my controller in an environment where it I could get it to run each action I wanted to test.


He finally consulted how the actual framework's tests were doing it and borrowed the setup from that - including several packages (via a "use") and the creation of the controller instance inside the setUp() method of the test set. Some other basic config is set up too including routing and event handling. He also includes examples of how to test this instance effectively - one showing a request with a parameter and another checking to ensure the 404 handler works when a non-existant resource is called.

Fortrabbit.com: Cloudscapes - Comparing PHP Cloud Hosting Platforms


On the Fortrabbit.com blog there's a new post that does a quick overview and comparison of 11 of the more popular cloud-based hosting platforms out there that are PHP friendly.



We are currently building yet another PHP Cloud Platform ourselves. Of course we looked around to see what the others are up to. This is my (Franks) personal point of view of the current market situation showcasing my favorite services. I try not to judge, neither i will compare features nor prices.

Services on his list include:


2012年7月10日星期二

Community News: Latest PECL Releases for 07.10.2012

Latest PECL Releases:

Community News: PHP, The Right Way Site Launches


In response to some of the recent talk about the quality of PHP and some of the recent suggestions about the right and wrong ways to write PHP, the PHP The Right Way site has been lunched.



There's a lot of bad information on the Web (I'm looking at you, W3Schools) that leads new PHP users astray, propagating bad practices and bad code. This must stop. PHP: The Right Way is an easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative tutorials around the Web. It is important to understand there is no canonical way to use PHP. That's the beauty of it. This website introduces new PHP developers to best practices, available options, and good information.


The site has some "getting started" tips for working with PHP 5.4, links to some of the current PSR standards and gets into some of the best practices for things like proper OOP structure, namespacing and using the SPL. There's also hints on using Composer for package management, working with databases and some basic parts on security and testing.



Additionally, the site is also an open source project so you can contribute your own content (it'll have to be approved before merging) on topics you might not see or want to improve.

Community News: CoderFaire Announced (Nashville, TN)


A new event has officially been announced for those in the Nashville area - CoderFaire, a 2 day event with a wide range of topics to appeal to all sorts of developers, not just the PHP folks.



From APIs to … some technology starting with a Z, and all points in between, we've got sessions to spark your creativity. You will hear about new technologies and learn new techniques as you listen to local speakers talk about how they are creating cool things here in Nashville. When you find you need a break, kick back in the lab and connect with a CoderFaire Nashville Lab Partner or other attendees. We'll have soft drinks and coffee aplenty to lubricate the conversations.

The schedule has also officially been announced and includes sessions like:



    Where MVC Ends, Services Begin - Ben Ramsey & Marcus Whitney
    Titanium Mobile Development - Andrew McElroy
  • GUIs Come and Go, CLI is Forever - Brian Dailey
  • Getting Results with Scrum & Kanban - Brendan Wovchko & Chris Hefley
  • Writing Code That is Easy to Change - Jesse Bunch


You can register for the event (happening August 25th) at $25 USD.

Nikita Popov's Blog: A plea for less (XML) configuration files


Nikita Popov has posted a plea to developers and project maintainers alike to stop using XML for their configuration files in their PHP-based applications.



I recently tried using Phing (a PHP build system) to do some simple release automation. Just creating a PEAR package and doing a few string replacements here and there. The result? After several wasted hours I ended up using Phing only for PEAR packaging and doing everything else in a custom PHP build script. The reason? Phing uses XML files to configure what it should do during a build.


He advocates a more native solution - a PHP script that defines the configuration options as a part of an object that can be injected into the parts of your app without the need for external dependencies.

2012年7月9日星期一

Matthew Weier O'Phinney's Blog: ZF2 Forms in Beta5


In this new post to his blog, Matthew Weier O'Phinney about some of the recent updates in the latest beta (beta5) of the Zend Framework 2's "Forms" component.



Forms are a nightmare for web development. They break the concept of separation of concerns: they have a display aspect (the actual HTML form), they have a validation aspect and the two mix, as you need to display validation error messages. On top of that, the submitted data is often directly related to your domain models, causing more issues. [...] Add to this that the validation logic may be re-usable outside of a forms context, and you've got a rather complex problem.


He talks about the newly-rewritten form component along with the new InputFilter to accompany it. He includes an example of using this new component - making a User form that, based off of some annotation rules, does some validation on the property values and things like "required" and custom types. He also talks about some of the other features included in the new package like hydration, complex annotation support and tools to work with collections.



You can download this latest beta release from the packages.zendframework.com site.

Michael Nitschinger's Blog: Announcing the Vienna PHP User Group


Michael Nitschinger has written up a new post to his blog talking about the formation of a new PHP user group in the Vienna, Austria area - ViennaPHP:



My goal is to create a friendly, welcoming and informative user group that allows beginners and experts alike to share their experiences, opinions and knowledge. I have always met great people when I worked with the open-source community and I think lots of people around here would benefit from it too. So, what next? The first thing we need to do is identify a bunch of developers (including you) that is willing to help me bootstrap the user group. I think the best way to do this is to first gather online and then meet for a beer or two and discuss what we can do next.


There's no formal meetings set - he's just trying to gauge interest and possibly find a few others to help him kickstart and manage the group (as well as find a location). If you're interested in the group, you can follow its account on Twitter or hit up Michael directly and let him know you're interested.

2012年7月6日星期五

Site News: Popular Posts for the Week of 07.06.2012

Popular posts from PHPDeveloper.org for the past week:

CodeIgniter.com: CodeIgniter Wiki Moved


As is mentioned in this new post to the CodeIgniter project's main site, their wiki has made a move. You can now find it on github.



In addition to having the convenience of existing as a git repo itself, moving this content to GitHub will help distinguish EllisLab and Reactor created content from community managed resources. It will also reduce the attraction of spammers to the CodeIgniter.com web site, as the wiki was a common location used by spammers and vandals to get content on our site that was less likely to be found and moderated than the frequently visited forums.


You can make changes if you see something incorrect by cloning the repo and making changes to the wiki repo and putting in a pull request.

The Bakery: 3.0: a peek into CakePHP's future


The Bakery (the CakePHP site) has posted a list of things to come in the 3.0 release of the popular PHP framework.



Since its creation, more than 7 years ago, CakePHP has grown with a life of its own. Its main goal has always been to empower developers with tools that are both easy to learn and use, leverage great libraries requiring low documentation and low dependencies too. We've had several big releases along these years and an ever growing community. Being one of the most popular frameworks out there and probably the first one (!) we have also gotten a lot of criticism from the developer community in general. We have, though, accepted it and learnt from our mistakes to keep building the best PHP framework there is.

Some of the coming improvements include:



  • Drop support for 5.2.x and support 5.4+ only
  • Use traits were possible and makes sense
  • Model layer rewrite
  • Improve Router
  • Improve bootstrapping process to allow more developer control and better performance


You can find more about the current features of the framework on it's main project site.

Raymond Kolbe's Blog: DOMPDF in ZF2


Raymond Kolbe has a recent post to his blog about using the DOMPDF library to generate PDFs in a Zend Framework 2 application.



If you're using Zend Framework 2 (beta 4) and need to easily generate PDFs, and you'd like to generate those PDFs from an HTML template, then boy do I have some good news for you! For those of you who have dealt with generating dynamic PDFs, you know how much of a pain in the ass it can be (e.g. dealing with x, y coordinates, word-wrap (or lack of), etc.). There are a few options out there, some paid, some free, but none of them are as nice as DOMPDF (simple API, powerful, and free). The true power behind DOMPDF comes from rendering standard HTML/CSS files instead of having to write ugly and unmanageable code.


He includes a simple example showing how to use the library to create a basic PDF document (containing an HTML string) and how to port that same thing over to work in ZF2 via a custom DOMPDFModule (a ViewModel). You can find out more about this module in it's README on github.

2012年7月5日星期四

Web & PHP Magazine: Issue #4 Published - "Safe and Secure"


The Web & PHP Magazine has published its latest issue, number 4, available for free download. Content in this month's issue include:



  • The "#Trending" column (hot and not in the PHP+web communities)
  • An interview with Matthew Weier O'Phinney
  • A wrapup of the International PHP Conference Spring 2012
  • Arne Blankerts on password handling
  • HTML5 Security considerations


Additionally, starting with this issue, you can also download previous issues of the magazine on their iPad application (for $0.99 per issue). The standard PDFs of each issue are still available for free, however. You can get this latest issue here.

Community News: PHP-FIG Group Launches Site & FAQ


To help resolve issues that have come up around its formation and to keep too much FUD (fear, uncertainty and doubt) from spreading, the "PHP-FIG" (framework interoperability group) has put together a site and a FAQ describing what they're all about.



The FIG stands for Framework Interoperability Group. The name until recently was "PHP Standards Group" but this was somewhat inaccurate of the intentions of the group. [...] The idea behind the group is for project representatives to talk about the commonalities between our projects and find ways we can work together. Our main audience is each other, but we're very aware that the rest of the PHP community is watching.


The FAQ answers other questions about the standards the group has agreed on (passed) so far, who the members of the group are, how to get involved and how framework communities can get involved.

PHPBuilder.com: Two PHP 5 Security Flaws Found


As reported in this new post on PHPBuilder.com, there are two new security issues that could allow an attacker to execute their own code (note: these are fixed by the latest releases, PHP 5.4.4 and PHP 5.3.14).



The flaws are related to each other, with the primary issue being an insecure implementation of the DES within the crypt() function. In his eSecurityPlanet article about recent PHP security updates, Sean Michael Kerner provides the details of these two security flaws.


The issue stems from a flaw in the DES implementation where certain keys are truncated before the DES digestion and a problem in the phar extension that could allow for arbitrary code execution. You can find more on these security issues here.

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

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

Juan Treminio's Blog: Xdebug and You: Why You Should be Using a Real Debugger


If you've been working with PHP for any length of time, you know that one of the issues the language has shows up when you're trying to debug your applications. Thankfully, as Juan Treminio points out, there's a better way - Xdebug.



Xdebug is a PHP extension that was written and is maintained by Derick Rethans. It provides debugging and profiling capabilities, although I'll be mostly focusing on the debugging aspects in this tutorial. With it you can set a breakpoint and pause the execution of a script to see the state of your application at that exact point, including what variables/objects have been instantiated and what their values are. Xdebug completely replaces the need to litter your code with echo, print_r() or var_dump() calls, and displays information on all variables, not just the one you passed.


He talks some about the current state of IDE/editor support for the tool and shows how to get it installed and your php.ini configured to use it. XDebug make it easy to turn on/off debugging thanks to a handy browser-based switch. He links to a bookmarklet you can use to make it a one-click operation. He includes the setup for using the debugging in PHPStorm, but it's pretty similar for most of the IDEs out there.

James Morris' Blog: Deploy a Silex App Using Git Push


James Morris has a new post to his blog showing you how you can deploy a Silex-based application via git and a post-receive hook on the server side.



Up until a few days ago I used to use a small bash deployment script to deploy a few simple sites to my live box. The process was a git archive and extract, then an rsync to the live site. Only inspecting it recently I realised that rsync no longer sent just the changes but all of the files, I'd never noticed before as the sites were so small the deploy was over very quickly. The rsync used to work fine before as I would deploy my current working code where the timestamps on files would match the server. Since I started using git at home for dev, the git archive method timestamps the files with the latest commit's timestamp. This messes up rsync.


His process involves a checked in version of Silex, a development branch, a push of the code to the live machine and an install script to set up Silex. He includes the "technical breakdown" and the information needed to replicate it - the .gitignore, setting up password-less SSHing, setting up the server and creating the git post-receive hook (a bash script).

Mike Purcell's Blog: PHP - Reflection Class - Determine Parent Method Signature


In this recent post to his blog Mike Purcell shares a method he found to discover the parameters required by a method in a class' parent via reflection.



According to PHP docs regarding the Memcached::get() method, there are three arguments which which must be added to my extended signature, which I added, but kept getting "...should be compatible with that of Memcached::get()" errors. I tried looking for the method signature via source code but didn't glean anything useful from the PECL documentation, so I turned to PHP's RelectionClass.


He includes a quick snippet of code showing how the check works and the handy output it produces - a set containing the parameter name, if it's require or optional and it's definition.

2012年7月3日星期二

Community News: Latest PECL Releases for 07.03.2012

Latest PECL Releases:

VG Tech Blog: Using Elastica to Query ElasticSearch


On the VG Tech blog today there's a new post by Christer Edvartsen about using the Elastica PHP Elastic Search client to do more than just pull information out of the data source. He dug into the source of the tool itself and figured out a way to perform actual queries.



The last couple of months I have been playing around with elasticsearch, an open source, distributed, RESTful search engine built on top of Apache Lucene. To interact with elasticsearch in PHP I have been using a client called Elastica. This was all fun and games until I needed to do actual queries, which is what our users will be doing most of the time. Elastica's documentation does not (yet) say anything about how to search using the client, so I needed to dig through the code to see if I could find some solutions.


He includes a sample mapping structure and shows how to take both a simple, single-term query and turn it into a request and how to make a more complex request with filters, facets, sorting and a few other things thrown in. He also shows how you can manually create a query (define the JSON structure yourself) and push that into the "query builder" for handling.

PHPMaster.com: Automate PSR Compliance through Jenkins


On PHPMaster.com today there's new tutorial showing how you can enforce compliance with the PSR standards in your application's code with the help of the Jenkins continuous integration tool.



Though it's still early to guarantee that the PSRs will be widely adopted as the de facto standard for writing serious PHP applications, it is interesting to note that a code sniffer and fixer that looks for code deviations was developed by nobody less than Fabien Potencier, the creator of the Symfony framework. (Et bien, ils ne sont pas fous, ces français!) In the rest of the article we shall find out what his PHP-CS-Fixer does and how can it be integrated with a CI tool like Jenkins.


He shows how to install a tool that can help you keep your source in compliance - the "fixer" (created by Fabien Potencier) to help correct the problems found in your code. He includes the command line calls you'll need to run the tool on your code and how to add the step to your build.