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

Master Zend Framework:
How to view an Instagram Photo Stream in Zend Framework 2
July 09, 2014 @ 10:53:59

On the Master Zend Framework site Matthew Setter has a new tutorial showing how to pull in Instagram photo feeds in a Zend Framework 2 application via their on developer functionality.

In today's tutorial, we're going to learn how to retrieve and display an Instagram photo stream in Zend Framework 2. We're going to cover the essentials of adding the libraries we'll need to composer.json, handling authentication and then retrieving and displaying our photo stream in a controller action. We'll be doing all of this by using composer to create a new Zend Framework 2 project, based on the ZF2 Skeleton App project and then add a new controller and action which will handle the work involved.

The tutorial uses a basic skeleton application and a PHP Instagram library to make the connection to their API. He shows you how to register your application with Instagram and set up the OAuth configuration to handle the authorization process. He walks you through the creation of the controller, setup of session support and the creation of a "photosAction" to view the results of the photo feed pull. He includes a screenshot of what the end result should look like with it all up and working.

0 comments voice your opinion now!
zendframework2 tutorial instagram photo feed api

Link: http://www.masterzendframework.com/api/view-instagram-photo-stream

Master Zend Framework:
Change Layout in Controllers and Actions in Zend Framework 2
June 27, 2014 @ 10:07:20

Matthew Setter has a new post to his Master Zend Framework site today showing you how to change layouts in controllers and actions for a Zend Framework v2 based application.

In Zend Framework 2, if you want to change the layout just for one action or for every action in a controller, how do you do it? How do you do it without overriding the layout for every action throughout the entire application? In today's post, based on an excerpt from Zend Framework 2 for Beginners, we see how to achieve both of these requirements.

He talks about the framework's use of the two-step view pattern and what the "template_map" definition usually looks like in a default ZF2 application. He shows three different ways to do the view switching from the controller or action:

  • Override the default layout in your module
  • Override the layout per/action
  • Override the layout per/controller

Each of these comes with a bit of code showing you how to make it work. They move from simplest to more complex, with the layout per controller being the most complex. It's not that it's difficult, it's just that there's more involved to make it work. You can either do it at the controller level or at the module level.

0 comments voice your opinion now!
tutorial zendframework2 controller action change ayout

Link: http://www.masterzendframework.com/views/change-layout-controllers-actions-zend-framework-2

Master Zend Framework:
Using the ClassMap Autoloader for Better Performance
June 19, 2014 @ 11:18:29

Matthew Setter has a new post to his Master Zend Framework site today with a recommendation on how you can use a classmap in your autoloader to reduce the time it takes "searching" for the files it needs.

Zend Framework 2′s been critiqued many times as being slow, at least slower than some of the other leading PHP frameworks. And to be fair, sometimes it's true. But it doesn't need to be and there are simple things you can do to improve performance of your applications. So this post will be the first in a multi-part series looking at ways in which you can improve the performance of your Zend Framework 2 application, with only a minimum of effort. Today, we're looking at the 2 autoloaders which are available in Zend Framework 2; these being the StandardAutoloader and ClassMapAutoloader.

He briefly introduces the concept of autoloaders and the PSR-0 standard that helped to bring a more unified method for their handling. He then gets into examples of using each of the two autoloader types. The Standard version (a fallback if nothing else is set up) resolves things based on a file path and locating classes in the right namespaces. The ClassMap autoloader does this mapping ahead of time and matches a path to a namespace+class. He includes code snippets showing how to set each of them up and a few statistics (using Apache's ab tool) of the difference in performance.

0 comments voice your opinion now!
zendframework2 tutorial autoloader classmap standard performance

Link: http://www.masterzendframework.com/performance-2/classmap-autoloader

Master Zend Framework:
Create a Simple File Upload Form in Zend Framework 2
June 04, 2014 @ 11:51:06

On his "Master Zend Framework" site today Matthew Setter has a new tutorial showing you how to create a simple file upload through the forms handling in Zend Framework 2. The form will include three parts: an input filter, a form class and a controller action to request to show the resulting form.

Having trouble getting file uploads integrated into your forms in Zend Framework 2? Or are you just curious about how to do it, and you want a quick rundown? If either of these is you, come walk through today's post with me as I show you a simple example of how it's done - along with how to combine it with filters and validators. Before we get started, I could have composed the code in a much shorter form than have I've composed it. But my assumption is that you're likely using the full-stack framework.

He includes summaries describing each of the three parts of the setup and the code you'll need to create each. The validator checks for things like "too big", "too small" and the correct MIME type on the file given. The form itself only includes the file upload element with a description of "Attachment". The controller action creates the form instance and calls an "isValid" when the upload happens to execute the validation. He also throws in the view template to display the form itself.

0 comments voice your opinion now!
zendframework2 simple file upload tutorial form

Link: http://www.masterzendframework.com/forms-2/simple-file-upload-form

Master Zend Framework:
Creating Custom ZFTool Diagnostic Classes
May 21, 2014 @ 11:23:59

Continuing on from his previous post introducing you to the ZFTool for Zend Framework 2 applications, Matthew Setter has posted part two of the series focusing on the creation of custom diagnostic classes for the tool.

In this week's tutorial, we're going to see how to step beyond the in-built classes and write our own custom checks. Specifically, we're going to write a check which runs php lint on the module's config file, module.config.php. The reason for doing this is because this file is so important in the configuration of a ZF2 module, that we should have a helpful sanity check for it.

He starts by helping you get all the needed dependencies in place, the ZFTool and ZendDiagnostics modules, installed via Composer. He includes code to help get started on the new diagnostic class and accompanying files. He implements some required methods from an interface, and shows how to enable its checking and define the configuration file. He includes a screenshot of the output so you can ensure things are working as they should be.

0 comments voice your opinion now!
zendframework2 zftool custom diagnostic class tutorial

Link: http://www.masterzendframework.com/zftool-2/creating-a-custom-zftool-diagnostic-class

Master Zend Framework:
How to Use ZFTool Diagnostics To Ensure Your Modules Work
May 13, 2014 @ 10:55:19

The Master Zend Framework site has a new tutorial today showing you how to use the ZFTool diagnostics to make sure your modules are working correctly. The ZFTool is a stand-alone tool that can help with common tasks like working with application configuration and creating module and project skeletons.

Do you want to be sure that when you create Zend Framework 2 modules, that they'll work in whatever environment they're used in? At the very least, do you want a simple way for users to check, as well as something that's self-documenting? If so, you're in the right place. Last year, I gave a basic introduction to ZFTool, which is a command line tool to manage applications written in Zend Framework 2. [...] In addition to [the included diagnostic checks] we can write our own diagnostic checks, using the Success, Failure and Warning classes. So in today's tutorial, I'm going to show how to add diagnostics support to a module.

He's broken the rest of the tutorial up into four other parts, each with the code or commands you'll need:

  • Add Diagnostics Support
  • The Diagnostics Function
  • Running Module Diagnostics
  • When Checks Fail

You can find out more about the ZFTool and its usage in with diagnostics in the official manual

0 comments voice your opinion now!
zftool module diagnostic validate zendframework2

Link: http://www.masterzendframework.com/zftool-2/use-zftool-diagnostics-ensure-modules-work

Jurian Sluiman:
SoflomoCache manage your ZF2 cache services
May 09, 2014 @ 09:53:32

Jurian Sluiman has posted about the release of a tool that aims to help you with cache handling in your Zend Framework 2 applications, the SoflomoCache component.

aching is an essential part in scaling your application, but Zend Framework 2 was missing a utility to manage your caches. Until now! During deployments we usually flushed the cache in a tedious and cumbersome way by directly accessing the apc_* functions in a custom script. This could certainly be improved and so we wrote a command line utility to manage all our cache services.

He includes a few snippets of code showing how to implement the component in your configuration and use it via ZF2's dependency injection handling. He also includes a list of the commands that can be used along with it to flush the cache, either all simultaneously or a single one (defined as a CLI option). It can also flush by namespace and handle the refresh of your combined configuration and module map.

0 comments voice your opinion now!
zendframework2 cache management component project service

Link: https://juriansluiman.nl/article/134/soflomo-cache-manage-your-zf2-cache-services

Master Zend Framework:
Using Sessions In Zend Framework 2 - Part 2
May 06, 2014 @ 11:18:26

The Master Zend Framework continues its series about using sessions in Zend Framework 2 applications. In part two of the series he focuses on validators and some of the backend storage options the framework makes possible.

In last week's tutorial we covered the basics of sessions in Zend Framework 2, looking at how to implement them by making changes to module/Application/Module.php so that they're available application-wide then how to both set and retrieve information in the session. In this week's tutorial, we're going to take last week's post further, by looking at session validation as well as different backends. These two things will help protect your session data from session hijacking, as well as help you scale your application, by storing the information using a more universal backend, which a filesystem most often times will never be.

He starts off with a bit of background about the structure of an average session in the framework is like, broken out into sections via the "Container" object. Then he starts in on the validators and describes a two of the built-in methods: "HttpUserAgent" and "RemoteAddr". A few code examples are included before he moves on to the backend options (like Cache, DbTable and MongoDB) using a "StorageFactory" object in the configuration.

0 comments voice your opinion now!
session zendframework2 part2 series validate backend

Link: http://www.masterzendframework.com/sessions/using-sessions-zend-framework-2-part-2

Master Zend Framework:
Using Sessions In Zend Framework 2 - Part 1
April 29, 2014 @ 12:09:49

On his Master Zend Framework site today Matthew Setter has posted the first part of a series looking at working with sessions in Zend Framework 2 applications.

To help work around [the stateless nature of the language], PHP introduced the concept of sessions, which allows for storing information across requests. However, like most things, as application's have become more complex, the ability to interact with sessions in a way that matches the needs of the application has continued to grow. Gladly, in Zend Framework 2, a set of classes is available, which helps reduce the complexity of managing session information, whether that's interaction, configuration or backend storage, without placing too much distance between you and the underlying PHP implementation, or adding too much complexity in the process.

Using the ZF2Skeleton as a base, he shows you how to add session support to the overall project in a few simple steps:

  • Update Module.php to initialize the session
  • Create a new container & store some data
  • Retrieve it later

There's not too much code change involved, but the snippets to add/update are included. In the next part of the series, he'll look at validation, preventing hijacking and using different backend storage methods.

0 comments voice your opinion now!
zendframework2 session tutorial series part1 introduction

Link: http://www.masterzendframework.com/sessions/using-sessions-in-zend-framework-2-part-1

Rob Allen:
Injecting dependencies into your ZF2 controllers
April 23, 2014 @ 09:06:27

Rob Allen has a quick new post to his site showing you how to inject dependencies into controllers in a Zend Framework v2 based application.

When starting working with Zend Framework 2, it's common to copy the skeleton and put your controller definitions in module.config.php. The controllers keyword is picked up by the ControllerManager which is an instance of the ServiceManager which means that it creates the controller instance for you when the dispatcher needs it. As it's just a service manager, we configure it to inject the dependencies that the controller needs rather than having to go fishing for them later.

He shows how to write a "getControllerConfig" method to populate two items into the factory call for a "Blog" controller, blog mapper and content mapper classes. He also includes a reminder that ZF2 controllers have no constructor, so dependencies can be more easily injected and used directly in the class.

0 comments voice your opinion now!
dependency injection controller zendframework2 tutorial factory

Link: http://akrabat.com/zend-framework-2/injecting-dependencies-into-your-zf2-controllers/


Community Events





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


laravel podcast testing opinion unittest install community configure refactor series threedevsandamaybe release list code framework introduction interview language experience developer

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