News Feed

News Archive
feed this:

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

Paul Jones:
A Response To "On php-fig and Shared Interfaces"
December 24, 2012 @ 12:54:57

Paul Jones has written up a response to Matthew Weier O'Phinney's recent post on shared interfaces and the PHP-FIG. In it he talks about the PHP-FIG group itself and specific references back to the original post.

He mentions the ideas of "new thinking" and the limitations that standardized interfaces might try to impose on an application:

One is able to imagine reasons why having shared interfaces of the kind described above is in opposition to, or at best orthogonal to, better development practices and greater innovation across PHP land. Even so, I assert that shared interfaces as described, while maybe preventing an imaginable ideal in theory, instead promote an actual good in practice.

Matthew Weier O'Phinney responded with some of his own comments and correcting some of the misinterpretation of his original comments.

0 comments voice your opinion now!
phpfig shared interface response comment

Anthony Ferrara's Blog:
To Comment Or Not To Comment - A Tale Of Two Stories
June 08, 2012 @ 11:02:20

In this recent post to his blog Anthony Ferrara looks at commenting in your application's code and how to be effective (and not so effective) when using them.

A few weeks ago I was sparked into a twitter conversation with Larry Garfield (@Crell) about the value of comments in code. [...] A pretty innocuous comment [about code that doesn't have comments] that is quite insightful. [...] That led to an interesting discussion that just couldn't fit on twitter. So let me explain...

He defines what he means by "comments" (DocBlock, general comments and legal information) and what sort of things should be inside of them. He also points out a few things not to do in you comments including being overly descriptive and restating what the code is doing (they should be less about that and more about the "Why"). Of course, there's exceptions and he touches on those briefly to finish out the post.

0 comments voice your opinion now!
comment code opinion useful

Gonzalo Ayuso's Blog:
Inject dependencies via PhpDoc
April 10, 2012 @ 10:23:14

Gonzalo Ayuso has a new post to his blog looking at a method for injecting dependencies into your application's code based on comments in the PHPDocumentor-formatted comments of your methods.

Last month I attended to Codemotion conference. I was listening to a talk about Java and I saw the "@inject" decorator. I must admit I switched off my mind from the conference and I started to take notes in my notebook. The idea is to implement something similar in PHP. It's a pity we don't have real decorators in PHP. I really miss them. We need to use PhpDoc. It's not the same than real decorators in other programming languages. That's my prototype. Let's go.

All of the code you'll need to recreate his solution is included - a sample "User" class that needs a valid PDO object in a private "db" property, a "DocInject" class that parses the comments and, using a new feature of PHP 5.4 (traits), injects the needed functionality into the "User" class and creates/assigns the object.

You can see just the full code in these two gists on Github.

0 comments voice your opinion now!
phpdocumentor comment tutorial injection traits

Rafael Dohms' Blog:
Book Review The Art of Readable Code
February 29, 2012 @ 10:41:12

Rafael Dohms has posted a new review of a book that focuses on helping you create better, more readable code - "The Art of Readable Code" (Dustin Boswell, Trevor Foucher, O'Reilly). This is isn't about "pretty code" as much as it is manageable, easy to follow structures and logic flows.

"The Art of Readable Code" was written by Dustin Bowell and Trevor Foucher and basically focuses on concepts and suggestions to make you code not just readable, but comprehendible by other developers, or as the author's suggest, yourself in six months. Code readability is a topic that I truly believe the PHP community does not focus enough on and i really wanted a look at this book to see what kind of ideas it had and what I could do my best to bring to the attention of other developers.

The book is language-agnostic and provides ideas that developers should keep in mind when doing their development - clear variable names, making comments that make sense, refactoring tips and hints for implementing your ideas in code. He recommends the book to any developer (in any language) to help them make code that will stand the test of time and be easier to manage/understand in the future.

0 comments voice your opinion now!
code readable book review oreilly clean comment naming refactor testing
Building a Domain Model - An Introduction to Persistence Agnosticism
February 27, 2012 @ 12:58:00

On there's a recent tutorial introducing the concept of a "domain model" and showing how to create them in PHP (manually, not inside of any ORM or database solution).

First off, creating a rich Domain Model, where multiple domain objects with well-defined constraints and rules interact, can be a daunting task. Second, not only is it necessary to define from top to bottom the model itself, but it's also necessary to implement from scratch or reuse a mapping layer in order to move data back and forward between the persistence layer and the model in question.

They include an example of a set of domain models tat relate to one another - a blog setup with posts, comments and users. They show how to create the AbstractEntity to handle a bit of the magic behind the scenes, an example "Post" and "Comment" models and how they can be put to work creating some posts and appending comments. A little bit of markup is included to output the results.

0 comments voice your opinion now!
domain model relation tutorial blog post comment user
Introduction to PhpDoc
January 10, 2012 @ 10:07:26

On today there's a new post from Moshe Teutsch about working with docblock comments in PHP scripts and how to use the phpDocumentor tool to generate the documentation from them.

If you've ever tried to read code written by someone other than yourself (who hasn't?), you know it can be a daunting task. [...] PhpDoc, short for PhpDocumentor, is a powerful tool that allows you to easily document your code via specially formatted comments. [...] By using PhpDoc, you can make it easy for others (and yourself) to understand your code - weeks, months, and even years after you've written it.

He introduces the concept of "docblocks" and includes several examples of how to comment things like packages, files, classes and functions/methods. Finally, he wraps up the post with an example of using the "phpdoc" command to run phpDocumentor and build the docs. In the comments, another tool is also suggested - DocBlox, a project that still parses the same docbloc syntax but does it in a much more memory efficient way (and is an actively maintained project).

0 comments voice your opinion now!
docbloc introduction phpdocumentor docblox comment phpdoc

Karsten Deubert's Blog:
Zend_MVC, Controller Plugins and Annotations
November 28, 2011 @ 12:02:50

Karsten Deubert has a recent post to his blog looking at annotations in Zend Framework applications to enhance functionality already in the framework.

Recently I had the idea to influence Controller Actions with annotations but discarded it with thoughts like "In PHP I will have to use reflection and some black magic to get this working which will have insane performance hits for my applications"... until I set everything up to see that it costs just 1-2ms in average per request without any form of caching.

He includes a few bits of code to show a simple annotation example (setting a layout) and the controller plugin that performs the translation. In his case, it's hard-coded to look for the "@layout" annotation in the docblock comment, but it'd be relatively trivial to extend it to a more full-featured version.

0 comments voice your opinion now!
zendframework mvc controller annotations docblock comment plugin

Matthew Weier O'Phinney's Blog:
Using DocBlox
August 04, 2011 @ 08:08:36

On his blog today Matthew Weier O'Phinney has a new post looking at an alternative to some of the other PHPDoc-based documentation tools, DocBlox, a tool written in PHP.

Until a few years ago, there were basically two tools you could use to generate API documentation in PHP: phpDocumentor and Doxygen. [...] phpDocumentor is practically unsupported at this time (though a small group of developers is working on a new version), and Doxygen has never had PHP as its primary concern. As such, a number of new projects are starting to emerge as replacements.

He introduces DocBlox as one of these alternatives and points out where you can get the latest version (from one of many sources including github, PEAR or by just grabbing a release. He includes instructions on how to run the tool on your code, use it to identify missing docblock comments and how to use the class diagrams feature that gives a more visual sense of how things fit together. He also mentions changing the title of the output, using different templates and how it uses a local SQLite database to cache the parsed information about your code (making it simpler and faster to do updates in the future).

0 comments voice your opinion now!
docblox docblock comment parse introduction

Integrate Facebook Comments Code with Wordpress or PHP
June 23, 2011 @ 12:16:19

On DevShed today there's a new tutorial showing you how to integrate Facebook commenting with your PHP application via the Facebook Connect API.

Facebook comments are a great way to optimize your site for social media and add a level of user-engagement to you site. Quality website comments can increase your website's credibility, as well as its traffic. This tutorial will teach you how to use Facebook's API Connect to integrate comment boxes on your website in a few simple steps, utilizing a little PHP and some elbow grease.

You'll need to set up an application for your PHP app to make the connection. This will give you the unique keys for your application that'll be used in setting up the commenting. By including a Facebook javascript file, all you'll need to do is output a special "fb" HTML tag with the right attributes and a meta tag or two to configure it with your application's keys.

0 comments voice your opinion now!
facebook comment integrate application tutorial

Gonzalo Ayuso's Blog:
Reflection over PHPDoc with PHP
April 04, 2011 @ 12:51:15

Gonzalo Ayuso has a new post to his blog today talking about a regular expression-laden script he's some up with to reflect over a PHP file and pull out the document's comments (PHPDoc-style).

I want to parse PHPDoc code. Let me explain a little bit what I want to do. Imagine a dummy function documented with PHPDoc. [...] PHP has a great reflection API, but as at least in the current PHP version (as far as I know) we only can get the PHPDoc as a string, without parse it. I need to get the parameters and the type of them with reflection. [...] But the type is different.

His script (based loosely on a bit of a component from the Zend Framework) parses the file and its comments and grabs the variable types from the PHPDoc blocks on each method and associates them.

If you're looking for a more mature solution than just this script, take a look at Docblox, a PHP 5.3 documentation generator.

0 comments voice your opinion now!
reflection tutorial phpdocumentor comment variable type

Community Events

Don't see your event here?
Let us know!

deployment install release update package community symfony list podcast zendserver language introduction opinion framework interview library tips laravel series api

All content copyright, 2014 :: - Powered by the Solar PHP Framework