Zend Framework 1 and Doctrine 2 integration – modular setup

Elink Media posts a followup;I’ve created a new branch on my Github project “zf1-doctrine2″.… [more]

Zend Framework 1 and Doctrine 2 integration – modular setup Zend Framework 1 and Doctrine 2 integration – modular setup

Adding Zend_Cache to Flex/Flash Builder 4 Projects

I have som rather large and time consuming queries running in the Statistics screen of an NOC (Network… [more]

Adding Zend_Cache to Flex/Flash Builder 4 Projects Adding Zend_Cache to Flex/Flash Builder 4 Projects

Zend_Amf and Flash Remoting — Some things to note — flex flash zf remoting

Having done a little bit of work with Flash over the past several weeks there are a couple of things… [more]

Zend_Amf and Flash Remoting — Some things to note — flex flash zf remoting Zend_Amf and Flash Remoting — Some things to note — flex flash zf remoting

Doctrine Tricks — SoftDelete

While pouring over some posts about Doctrine I stumbled upon a very nice solution to the Cascading Delete… [more]

Doctrine Tricks — SoftDelete Doctrine Tricks — SoftDelete

Setting Up Doctrine for Zend Framework 1.9.x

After some fiddling and googling and Zendcast watching :) I figured out how to get the models to generate… [more]

Setting Up Doctrine for Zend Framework 1.9.x Setting Up Doctrine for Zend Framework 1.9.x

Zend_Server Class

e_schrade wrote a neat way of doing things in the ser­vice layer; Let’s take a quick look at some­thing that’s kind of neat in Zend Frame­work. I’ve been doing some work with Adobe on some arti­cles and one of them was on work­ing with mobile clients with Flash. Well, me being the masochist I did more. What I did was write an exam­ple that worked as a full web­site, an Ajax web­site, a Flash ser­vice and an XML-RPC service.

Looks like a lot, right?  Actu­ally there’s not much there.  Here’s the logic flow.

  • Is it an XMLHTTP Request and is it a POST? Cre­ate the Json server
  • Is it an AMF request? Cre­ate the AMF server
  • Is it an Xml­Rpc request? Cre­ate the Xml­Rpc server
  • Is it an XMLHTTP Request and is it a GET? Cre­ate the Ser­vice Map (for JSON-RPC 2.0)
  • If a ser­vice han­dler has been cre­ated add all of the application’s map­pers, attach the ser­vice han­dler to the request and redi­rect to the ser­vice action.

And with that you have an appli­ca­tion that can serve con­tent for mul­ti­ple dif­fer­ent types of ser­vice with almost no effort on your part.  At least.. if you copy and paste this code.

Have a good Friday!!!

via Zend_Server — zf ffh zend_server on e_schrade — zend php.

Finding syntax errors in your PHP Project files

Till posted this lit­tle snip­pet;
It’s so use­ful I just had to share it :)

find . \( -name "*.php" -o -name "*.phtml" \) -exec php -l {} \;

Just go to your project direc­tory and fire it off, it will help you find those pesky unmatched {}

Tags: ,
Posted in Development PHP Useful Tools by Danny Froberg. No Comments

Search each class for function names that match except for the underscore prefix

Bill Kar­win posts a use­ful lit­tle snip­pet that will list and search each class for func­tion names that match except for the under­score pre­fix, pri­vate / pro­tected functions.

<?php
/**
  * Find methods that differ only by the underscore prefix.
  * by Bill Karwin August 2010
  *
  * I release this code under the terms of the New BSD License:
  * http://framework.zend.com/license/new-bsd
  */


// Change this to suit your environment
define("LIBRARY_DIR", "/Users/bill/Library/PHP/ZF/library");

// Pre-load some files to satisfy the autoloader.
// We could also add the local PEAR library dir to the autoloader.
require_once("PHPUnit/Framework/SelfDescribing.php");
require_once("PHPUnit/Framework/AssertionFailedError.php");
require_once("PHPUnit/Framework/Assert.php");
require_once("PHPUnit/Framework/Test.php");
require_once("PHPUnit/Extensions/Database/DataSet/ITable.php");
require_once("PHPUnit/Extensions/Database/DataSet/AbstractTable.php");
require_once("PHPUnit/Extensions/Database/DataSet/IDataSet.php");
require_once("PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php");
require_once("PHPUnit/Extensions/Database/ITester.php");
require_once("PHPUnit/Extensions/Database/AbstractTester.php");

require_once(LIBRARY_DIR . "/Zend/Loader/Autoloader.php");
Zend_Loader_Autoloader::getInstance();

// Find every PHP file under the library dir and slurp them in.
// Yes that's a lot of files.  Deal with it.
$Directory = new RecursiveDirectoryIterator(LIBRARY_DIR);
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '/^.+\.php$/i'); foreach ($Regex as $filename) {
   require_once($filename);
}

// Loop over each class now in the PHP runtime.
// Filter by classes named Zend*.
$classes = get_declared_classes();
$zendclasses = new RegexIterator(new ArrayIterator($classes), '/ ^Zend/'); foreach ($zendclasses as $classname) {

   // Search each class for function names that match except for the underscore prefix
   // Note this includes duplicates and magic methods, so you have to do some sorting
   // on the output.  Hint: `sort -u`.
   $class = new ReflectionClass($classname);
   $methods = $class->getMethods();
   foreach ($methods as $method) {
     if (preg_match("/^__*(.*)/", $method->name, $matches)) {
       $underscore = $method;
       if ($class->hasMethod($matches[1])) {
         $nonunderscore = $class->getMethod($matches[1]);
         echo $underscore->getDeclaringClass()->name
           . "::" . $underscore->name . "()" . " => ";
         if ($underscore->getDeclaringClass() != $nonunderscore->getDeclaringClass()) {
           echo $nonunderscore->getDeclaringClass()->name;
         }
         echo "::" . $nonunderscore->name . "()" . "\n";
       }
     }
   }

}
Tags: ,
Posted in Development PHP by Danny Froberg. No Comments

Testing Zend Framework controllers in isolation

What I do is I have my con­trollers fetch all their depen­den­cies from the boot­strap and/or front con­troller. The most com­mon exam­ple is to pull the db resource from the bootstrap:

// in controller
$db = $this->getInvokeArg('bootstrap')->getResource('db');

But I also take it a step fur­ther. For exam­ple, if I’m using data map­pers, I have the action con­troller check the front con­troller for the data map­per I need:

// in controller
$postsMapper = $this->getInvokeArg('posts_mapper');

I then update your unit test to inject the posts map­per with a stub:

// in unit test
$this->frontController->setParam('posts_mapper', $stubPostsMapper);

How­ever, that invoke arg won’t exist in pro­duc­tion, so I wrap that call in an if state­ment a la “lazy load­ing” style:

if (null === ($postsMapper = $this->getInvokeArg('posts_mapper'))) {
    $postsMapper = new Default_Model_Mapper_Posts();
}

What this does is it allows me to stub in my stub posts map­per in my unit tests while let­ting the con­troller lazy-load the real one in production.

An alter­na­tive is to use Zend_Registry, but I find this to be a bit cleaner with­out the sta­tic calls.


Hec­tor Virgen

Zend Framework 2.0 (2.0.0dev1)

Yes­ter­day, the Zend Frame­work team tagged the first devel­op­ment mile­stone of Zend Frame­work 2.0 (2.0.0dev1). It is imme­di­ately down­load­able from the Zend Frame­work servers:

* Zip package:

http://framework.zend.com/releases/ZendFramework-2.0.0dev1/ZendFramework-2.0.0dev1.zip

* tar.gz package:

http://framework.zend.com/releases/ZendFramework-2.0.0dev1/ZendFramework-2.0.0dev1.tar.gz

NOTE! This release is not con­sid­ered of pro­duc­tion qual­ity, and is released solely to pro­vide a devel­op­ment snap­shot for pur­poses of test­ing and research. Use at your own risk.

This release is the cul­mi­na­tion of sev­eral months of work, and incor­po­rates the fol­low­ing features:

* Removal of all require_once statements.

* Migra­tion to namespaces.

* Refac­tor­ing of the test suite, including:

* Removal of all “AllTests.php” files.

* Removal of unref­er­enced test classes.

* Lim­ited refac­tor­ing to move helper classes into their own files.

* Refac­tor­ing of con­di­tional tests.

* Rewrite of Zend\Session from the ground up. This required cre­ation of a new com­po­nent, Zend\SignalSlot, for han­dling observers and cre­at­ing fil­ter chains.

* Addi­tion of a new Zend\Stdlib name­space for inter­faces and util­ity classes; in par­tic­u­lar, we added exten­sions to SplQueue, SplStack, and  Spl­Pri­or­i­tyQueue to cre­ate seri­al­iz­able ver­sions of these classes.

We have done some “real-world” test­ing of the release by build­ing the Quick Start appli­ca­tion, as well as migrat­ing an exist­ing demo appli­ca­tion to ZF2. We were able to achieve both goals, demon­strat­ing that while the release is cer­tainly pre-alpha, it is def­i­nitely functional.

There is much work yet to be done. Today, we pub­lished a rough roadmap of mile­stones we will be work­ing towards (1). This roadmap only addresses com­po­nents with cross-cutting con­cerns, but serves as a guide for devel­op­ment in the com­ing months. If you are inter­ested in con­tribut­ing, be sure to sign our Con­trib­u­tors License Agree­ment (CLA), and read the “README-DEV.txt” file in the release. We also sug­gest you join the zf-contributors mail­ing list (2), and join in dis­cus­sions on the #zftalk.dev IRC chan­nel on Freenode.

[1] http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Milestones

[2] http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html

Matthew Weier O’Phinney

Tags:
Posted in Development Zend Framework by Danny Froberg. No Comments

Autocomplete Control with ZendX_JQuery

Jon Leben­sold posts; In the last video, I dis­cussed ZendX_JQuery inte­gra­tion. Now we’re going to take it a step fur­ther by devel­op­ing our own jQuery auto­com­plete con­trol, using a coun­try list, PHP 5.3 and anony­mous functions.

Grab a copy of the project or browse the repos­i­tory.

via Zend­casts.

Working with ZendX_JQuery

Jon Leben­sold posts; I’ve received a lot of feed­back about jQuery inte­gra­tion in the Zend Frame­work. This lit­tle video will show you how you can quickly inte­grate jQuery and jQuery UI into your Zend Frame­work project.

Grab a copy of the project or browse the repos­i­tory.

via  Zend­casts.

A contents index for Zend Framework manual pages

The good old Zend Frame­work man­ual pages do suf­fer from being some­what lengthy. I’ve thought they could do with an index to make nav­i­ga­tion eas­ier on those oh-so-long pages. So I wrote a quick JavaScript book­marklet to do just that.

via  simon r jones.

Tags:
Posted in Documentation Zend Framework by Danny Froberg. No Comments

Tutorial: Getting Started with Zend_Auth

Rob Allen writes; After too many months of neglect, I have com­pletely rewrit­ten my Zend_Auth tuto­r­ial so that it is com­pat­i­ble with Zend Frame­work 1.10!

As an exper­i­ment, I have writ­ten it directly in HTML, rather than PDF as before and cover the login form along with the login con­troller code required to authen­ti­cate a user using a data­base table. For good mea­sure, I’ve included log­ging out and a view helper to show how to access the logged in user’s details.

The full source code is also avail­able, if you don’t want to type it in :)

I hope you find it useful.

Tuto­r­ial: Get­ting Started with Zend_Auth – Rob Allen’s DevNotes.

Introduction to WSDL

Jeroen Kep­pens writes; Recently I had to cre­ate a soap web­ser­vice. The WSDL gen­er­a­tor put in too much, so I decided to make the WSDL myself. Luck­ily a col­league gave me a quick intro.

via Jeroen Kep­pens : Intro­duc­tion to WSDL.

Tags:
Posted in Development by Danny Froberg. No Comments

OpenStack Web Control Panel in Launchpad

Cap­puc­cino based web appli­ca­tion to man­age Open­Stack com­pute and storage.

The Open­Stack Open Source Cloud Mis­sion: to pro­duce the ubiq­ui­tous Open Source Cloud Com­put­ing plat­form that will meet the needs of pub­lic and pri­vate cloud providers regard­less of size, by being sim­ple to imple­ment and mas­sively scalable.

via Open­Stack Web Con­trol Panel in Launch­pad.

Tags:
Posted in Cloud Development by Danny Froberg. No Comments

OpenStack.org: RackSpace Open Sources Their Cloud Services Platform, And Gets NASA On Board

Host­ing com­pany Rack­Space is open sourc­ing the soft­ware behind its cloud stor­age and com­put­ing plat­forms on Mon­day, the com­pany is say­ing. The com­pany is also prepar­ing to launch Open­Stack, an open source cloud plat­form, and will donate the open source code to that project.

NASA is also incor­po­rat­ing tech­nol­ogy from the NASA Neb­ula Cloud Plat­form into the Open­Stack project, says RackSpace.

Rack­Space says they want to drive inter­op­er­abil­ity in cloud ser­vices to avoid ven­dor lock-in, and help cre­ate indus­try stan­dards. More than 25 com­pa­nies have shown inter­est in the project, says Rack­Space, or are actively work­ing on the code. They include AMD, Cit­rix, Cloud.com, Cloud­kick, CloudSwitch, Dell, enStra­tus, Fath­omDB, Lime­light, Nicira, NTT DATA, Opscode, Peer 1, Pup­pet Labs, RightScale, Rip­tano, Scalr, Son­ian, Spice­works and Zuora.

The code is being released under the extremely flex­i­ble Apache 2 license, mean­ing third par­ties can redis­trib­ute the code, build pro­pri­etary soft­ware around the code, and dis­trib­ute it with few restrictions.

Tags:
Posted in Cloud Development by Danny Froberg. No Comments

Complete Doctrine 1.2x Integration with Zend Framework 1.10+

To achieve com­plete Doc­trine 1 inte­gra­tion with Zend Frame­work some glue is required, Ben­jamin Eber­lei has cre­ated a com­plete solu­tion thats straight for­ward, easy to use and understand.

This project tries to offer a com­plete Inte­gra­tion of Doc­trine 1 with Zend Frame­work. The fol­low­ing com­po­nents belong to this Integration:

  • Zend_Application Resource
  • Zend Frame­work Mod­u­lar Project Support
  • Zend_Tool Provider for Doc­trine Model Gen­er­a­tion, Migra­tions and Fixtures
  • Zend_Paginator Adapter for Doc­trine Queries
  • Dynamic Zend_Form gen­er­a­tion from Doc­trine Models

This inte­gra­tion requires the lat­est Doc­trine ver­sion 1.2.2 to work completely

Get it!

SVN Export or Externals

Github offers SVN Read sup­port for a while now, you can either use svn export or svn:externals to include ZFDoc­trine into your project or into your PHP Include Path.

svn checkout http://svn.github.com/beberlei/zf-doctrine.git

Git Clone

git clone git://github.com/beberlei/zf-doctrine.git

If you fol­low the tuto­r­ial and instal­la­tion steps your will get this in ZFTool.

Zend Framework Command Line Console Tool v1.10.4
Actions supported by provider "Doctrine"
  Doctrine
    zf create-project doctrine dsn zend-project-style library-per-module single-library
    zf build-project doctrine force load reload
    zf create-database doctrine
    zf drop-database doctrine force
    zf create-tables doctrine
    zf generate-sql doctrine
    zf dql doctrine
    zf load-data doctrine append
    zf dump-data doctrine individual-files
    zf generate-models-from-yaml doctrine
    zf generate-yaml-from-models doctrine
    zf generate-yaml-from-database doctrine
    zf generate-migration doctrine class-name from-database from-models
    zf excecute-migration doctrine to-version
    zf show-migration doctrine
    zf show doctrine

Read it ALL at beberlei’s zf-doctrine at mas­ter — GitHub.

Selectively Adding CSS with Zend_Layout

Jon Leben­sold post another screencast;

This video out­lines a lit­tle trick I’ve found immensely help­ful in larger appli­ca­tions: man­ag­ing your css selec­tively. Luck­ily, the Zend Frame­work is built with some great fea­tures for han­dling this case using Zend_View and Zend_Layout. Enjoy!

Grab a copy of the project or browse the repos­i­tory.

via Zend­casts.

Painless HTML Emails with Zend_Mail

Jon Leben­sold posts a  quick video explain­ing how quickly and easy it is to write designer-friendly HTML emails using Zend_View and Zend_Mail.

Grab a copy of the project or browse the repos­i­tory.

via Zend­casts.

(Sorry for the late addi­tion of this)

Get Adobe Flash playerPlugin by wpburn.com wordpress themes