 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Rob Allen: Simple logging of ZF2 exceptions
by Chris Cornutt April 25, 2013 @ 10:31:40
In this new post to his site Rob Allen shows you how to implement a simple logging method for catching exceptions in your Zend Framework 2 application.
I recently had a problem with a ZF2 based website where users were reporting seeing the error page displayed, but I couldn't reproduce in testing. To find this problem I decided to log every exception to a file so I could then go back and work out what was happening. In a standard ZF2 application, the easiest way to do this is to add a listener to the 'dispatch.error' event and log using ZendLog.
He uses an event listener to attach a service that contains a "logException" method. This method uses the ZendLog component to write out the error message to a local log file including a backtrace of where the issue occurred.
voice your opinion now!
simple logging exception handling service event listener tutorial
Reddit.com: Dependency injection in ZF2 and Symfony 2 are service locators
by Chris Cornutt April 16, 2013 @ 12:40:07
On Reddit's PHP section there's a discussion happening about dependency injection versus service locators in two popular PHP frameworks - Zend Framework 2 and Symfony 2 (and how they're not really DI at all).
Both ZF2 and Symfony 2 offer the same behavior: if I'm in a controller, and I want to use a service, I have to get it from the container with $this->get('my_service').
As such, the controller is not using DI, this is the service locator pattern. Controllers become more difficult to tests because of that, and they depend on the container now. I wonder why both frameworks didn't go further: why not treat controllers like services and use dependency injection on them. In other words: if a controller needs a service "A", then it should get it in the constructor, or through setter/property injection.
The comments talk some about the "controller from the DI container" idea, some other ways around the problem and some clarification as to what the frameworks are actually doing related to the container injection.
voice your opinion now!
dependency injection service locator controller framework zendframework2 symfony2
Rob Allen: Objects in the model layer
by Chris Cornutt March 22, 2013 @ 10:45:54
In this latest post to his site Rob Allen talks some about application structure and the different kinds of objects he uses in his applications.
I currently use a very simple set of core objects within my model layer: entities, mappers and service objects. [...] I dislike the phrase "service object" as the word "service" means so many things to so many people. I haven't heard a better phrase yet that everyone understands though.
He defines each of the types of objects to help make the separation clearer. Here they are in brief:
- Entities are objects that represent something in my business logic.
- Mappers know how to save and load an entity from the data store.
- Service objects provide the API that the rest of the application uses.
Some of the comments on the post relate his choices to use in Zend Framework v2-based applications, noting that there are some base components you can extend to create these kinds of objects.
voice your opinion now!
object model entity mapper service oop structure znedframework2
Gonzalo Ayuso: How to configure Symfony's Service Container to use Twitter API
by Chris Cornutt February 05, 2013 @ 10:53:19
In this recent post to his site Gonzalo Ayuso shows how to use the Symfony2 service container to interact directly with the Twitter API via an OAuth plugin.
If we are working within a Symfony2 application or a PHP application that uses the Symfony's Dependency injection container component you can easily integrate this simple script in the service container. I will show you the way that I use to do it.
His sample code uses the Guzzle HTTP library and some configuration options from a YAML file to create a new service hooked into the Twitter API with his credentials. He then imports it via his services configuration and shows an example of it in action - getting the latest contents of his timeline.
voice your opinion now!
symfony2 service container guzzle twitter api
7PHP.com: Zend Certifications Tips & Tricks - Michelangelo van Dam
by Chris Cornutt February 04, 2013 @ 11:22:16
On 7PHP.com today there's a new interview posted, a different kind of one from their usual "community spotlight" series. In this new article they talk with Michelangelo van Dam about the Zend Certified Engineer test and any advice he can offer to those wanting to take it.
This is the 1st set of Zend Certification Tips and Advice to help anyone taking either of the two Zend Exams powered by Zend Technologies: the Zend PHP Certification Exam and/or the Zend Framework Certification Exam. The aim being to help people who want to sit for those exams and inform them what it is all about & what to expect by hearing it from (pro) PHP Guys who have already been through it, that is.
There's a long list of questions in the interview covering a wide range of things about the test everything from what its about out to some of Michelangelo's own opinions about the tests:
- Can you briefly give us an idea of what ZC is about, what it tries to achieve?
- Can you give us an idea of what need to be studied and what kind of stuffs we should expect..etc
- Parts of the modules that you think is more complex and one should pay special attention to?
- What TWO questions can you remember that you can share with us
- Do you recommend PHP guys to get certified?
Check out the answers to these and more questions in the full interview.
voice your opinion now!
zend certification zce framework zfce interview michaelangelovandam opinion
|
Community Events
Don't see your event here? Let us know!
|