News Feed
Sections




News Archive
feed this:

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

JetBrains.com:
Live Webinar PHP Annotations - They exist! Join us June 11th.
June 06, 2014 @ 11:54:00

JetBrains has announced a webinar they'll be holding on June 11th at 4:00pm CEST (10am EDT) with host Rafael Dohms covering annotations in PHP.

Annotations are more than PHPDoc comments, they're a fully-featured way of including additional information alongside your code. We might have rejected an RFC to add support into the PHP core, but the community has embraced this tool anyway! This session shows you who is doing what with annotations, and will give you some ideas on how to use the existing tools in your own projects to keep life simple. Developers, architects and anyone responsible for the technical direction of an application should attend this session.

Space for the webinar is limited, so if you're interested in attending be sure you sign up quickly. There's no charge for the event, you'll just need to provide a bit of information prior to signup.

0 comments voice your opinion now!
annotation webinar rafaeldohms jetbrains

Link: http://blog.jetbrains.com/blog/2014/06/03/live-webinar-php-annotations-they-exist-join-us-june-11th

VG Tech:
Swagger Docs in ZF2 with Examples - Part 1 Setup and Annotations
February 25, 2014 @ 10:33:48

The VG Tech blog has posted the first part of a series they're doing about Zend Framework 2 and Swagger, the auto-generating documentation project for APIs. In this first part of the series, they go through some setup and show the use of annotations to define the Swagger output.

So everyone is building APIs now - parsing and outputting JSON is not that hard. Some people even build truly RESTful APIs, or something not to far from that. Before, when building APIs was about SOAP with XML schemas and WSDL specifications, people spent so much time building their APIs that they had the time to think. Now, building an API is so easy and fast that the documentation is often suffering. [...] Swagger is a popular project providing auto generated API docs based on a service specification. This spec is based on annotation comments in the controllers and models, giving the developer a fairly easy, and close to the code way of keeping the API docs up to date.

He walks you through the process to clone and setup the Zend Framework 2 project first, then pull in the "outeredge/swagger-module" with Composer. This package provides the tools to generate Swagger output from annotations in the PHP code. He also shows you how to set up the Swagger UI project (wordnik/swagger-ui). Finally, he gets into the code examples, showing how to annotate models and use partials.

0 comments voice your opinion now!
swagger api zendframework setup annotation tutorial series part1

Link: http://tech.vg.no/2014/02/24/swagger-docs-in-zf2-with-examples-part-1-setup-and-annotations/

Matthew Weier O'Phinney's Blog:
ZF2 Forms in Beta5
July 09, 2012 @ 09:34:05

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.

0 comments voice your opinion now!
zendframework2 form component beta5 annotation tutorial


Matthew Weier O'Phinney's Blog:
On Visibility in OOP
June 29, 2012 @ 09:52:03

Matthew Weier O'Phinney has a new post to his blog today looking at visibility in OOP in PHP - less about the features the language offers and more about the theory of their use.

I'm a big proponent of object oriented programming. OOP done right helps ease code maintenance and enables code re-use. Starting in PHP, OOP enthusiasts got a whole bunch of new tools, and new tools keep coming into the language for us with each minor release. One feature that has had a huge impact on frameworks and libraries has been available since the earliest PHP 5 versions: visibility.

He covers a bit of the syntax and features of public, private and protected and mentions a keyword not often seen in PHP applications - final. The reason all of this came up was work on annotation support in Zend Framework 2 and some difficulty in integrating it with Doctrine support. The "final" status of the class was part of the problem, and after a a lot of copy & pasting he decided on a different tactic - using its public API to try to work around the problem.

In sum: because the class in question was marked final and had private members, I found myself forced to think critically about what I wanted to accomplish, and then thoroughly understand the public API to see how I might accomplish that task without the ability to extend.
0 comments voice your opinion now!
visibility oop final annotation doctrine


Mike Purcell's Blog:
PHPUnit - How to Run PHPUnit Against a Specific Test
February 01, 2012 @ 08:37:03

Mike Purcell has a quick new post to his blog showing how you can run PHPUnit on one specific test using handy grouping functionality already built into the tool.

The other day I was debugging an error in one of my unit tests, and found it hard to track down because when I ran PHPUnit, it ran all the tests contained in the file where my problem unit test was located. After some Googling and reading the PHPUnit Api Docs, I found that you can specify a test, among other tests, by adding a comment with the @group annotation.

Using this "@group" annotation tells PHPUnit to combine these tests and allows you you specify a "--group" setting on the command line to only run those. He includes some sample code showing how it can be used. This can be very useful for combining results for certain kinds of tests (say, all related to bugfixes) without having to run everything all over again.

0 comments voice your opinion now!
phpunit specific test group annotation


Andrew Eddie's Blog:
Making the most out of Code Assist in Eclipse/PDT and Zend Studio for PHP
December 01, 2011 @ 12:55:32

Andrew Eddie has posted a helpful tutorial for Eclipse users out there showing how to get the most our of code assist in Eclipse PDT/Zend Studio.

One of the powerful features of an IDE like Eclipse is the ability for it to "read" your code and give you some assistance about your API as you type. This could include things like class property or methods names, constants, functions, argument lists, and so on. Eclipse/PDT and ZendStudio do this by parsing a PHP class directly, but they also look at your docblocks and some other special comments where the raw PHP is not enough. This article is a bag of tricks that help you get the most out of code assistance using Eclipse/PDT or Zend Studio in those awkward corners of your code that you might have through previously inaccessible.

Among his tips are things like adding "@var" declarations to help with code completion, type hinting on methods/functions, using the "@property" annotation and using a "this" trick to override what class the IDE sees as the local object. ,/p>

0 comments voice your opinion now!
eclipse zendstudio ide hint trick docblock annotation codeassist


Volker Dusch's Blog:
An introduction to PHPUnits @covers annotation
November 04, 2011 @ 09:55:32

PHPUnit is one of the most widely used unit testing tools for PHP applications. It comes packed with features, some that are commonly used and some not so much. In a new post to his blog today Volker Dusch looks at one specific feature - the "@covers" annotation you can use in your tests' comments to specify which functionality you're actually testing.

One of the goals of your test suite and the coverage report is to make you trust in your code base and to remove the fear of changing something that needs to be changed. [...] You shouldn't think "Well yes that a 100% but a lot of that just comes from that big integration test and I don't know if the class is really tested!". [...] Thankfully PHPUnit offers a way to drastically increase your confidence in what you actually have tested.

Using the "@covers" annotation on your test method docblocks gives you one more level of confidence in what's being tested and can help make for clearer updating down the road. He also mentions using them to provide extra insight into protected methods in your code and where the test coverage for them really lies.

0 comments voice your opinion now!
phpunit covers annotation protected methods codecoverge


SitePoint.com:
Advanced PHPUnit Testing Annotations and Mocking
February 17, 2011 @ 09:33:08

On SitePoint.com today there's a new article in their unit testing series posted today - a look at annotations and mocking in advanced unit testing with PHPUnit. (Disclaimer: I am the author of this article series.)

PHPUnit has lots of advanced features that can be amazingly helpful when that special case comes around. This includes extending the framework itself, making test suites, building static datasets, and the focus of this article: annotations and mocking. Don't worry if you're unsure what either of these are; I'm here to help. I trust by the end that you'll see how these two features can be useful to both you and your tests.

The article starts with annotations showing how they can be used both on the class side to help with test generation and on the test side to help in evaluation (like expectedException). In the mocking section, it shows you how create simple and complex mock objects to replace a sample database query.

0 comments voice your opinion now!
tutorial unittest annotation mocking phpunit testing


Stubbles Blog:
On annotations and logic
January 28, 2011 @ 12:29:40

On the Stubbles blog there's a recent post that talks about a feature they introduced into the framework - annotations - with high hopes it would give them more flexibility in how things worked. As Frank Keline says, though, "it's not such a good idea at all".

The most simplest reason for this is the idea that annotations are markup. They mark (or, to keep the notion, annotate) code as being special or to be treated in some special kind of way, depending on the scenario where the code is used in. [...] From a design point of view this makes it clear why annotations should not contain logic. If annotations contain parts of such logic, it becomes splitted and possibly cluttered throughout different classes.

He goes on to talk about a second reason why he doesn't think they should be considered first-class in an application - it doesn't promote code reuse. For example, if you define them on a method, there's no way to use that method without them. He puts this into the perspective of the Stubbles framework that currently uses them and how he's changed the logic to live in special classes instead. He considers other changes like places annotations can be used and having different annotation classes.

0 comments voice your opinion now!
annotation logic framework stubbles opinion


Change Garcia's Blog:
expected exceptions annotations, mocked object calls, oh my.
December 28, 2010 @ 11:42:27

Chance Gracia came across an interesting feature/bug when writing up unit tests for his application with PHPUnit. He was throwing an exception from a mock object and based on his annotation the exception is caught no matter the type.

Anyone who has worked with PHPUnit has most likely worked with expected exceptions and mock objects. The nice thing about working with expected exceptions is that we have access to a handy @expectedException annotation. I've gotten into the habit of using this for exceptions my fixtures should throw but also for when I'm using a mock object to verify a method call.

Some sample code is included to show his problem - a mock object is created for the "foo" class and a test to see if an Exception type is thrown is included on it. The problem is that the exception thrown isn't of type Exception, but of type "foo_exception" and the @expectedException annotation tells it to look for the Exception type. Because of this unpredictable behavior, he suggests not using annotations for these sort of tests or it could lead to false positives.

1 comment voice your opinion now!
annotation phpunit unittest exception custom expectedexception



Community Events





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


list interview release code community tips deployment api symfony conference bugfix zendserver introduction series laravel language voicesoftheelephpant threedevsandamaybe framework podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework