Introducing Sencha Architect 2


Sen­cha Archi­tect 2.0 builds on our inno­va­tion in Ext Designer. Now, you can build Touch and Ext JS apps through drag and drop. Avail­able for Mac, Win­dows, and Linux. Down­load Sen­cha Archi­tect 2

When we started work­ing on the next release of Ext Designer, we had very ambi­tious goals: we wanted to build a great visual tool to help you build web appli­ca­tions faster that didn’t get in the way. We wanted to make the devel­op­ment process more inclu­sive by low­er­ing the bar­rier to col­lab­o­rate, allow­ing UX design­ers to work effec­tively in the same envi­ron­ment that you use.

We wanted you to be able to cre­ate com­plete appli­ca­tions – not just the UI. We wanted a tool that would let you build an appli­ca­tion quickly out of stan­dard com­po­nents, but also allow you to eas­ily cus­tomize those com­po­nents with your own code, right from within the tool.

What we cre­ated is no longer just a rapid inter­face designer, but a com­plete appli­ca­tion builder, a place where the archi­tec­ture and the inter­face of an appli­ca­tion can be cre­ated and prop­erly struc­tured for development.

For this rea­son, the name “Designer” no longer accu­rately cap­tured what the prod­uct enabled: it’s now much, much more than a sim­ple UI designer. And so, it is our plea­sure to intro­duce the all-new Sen­cha Archi­tect 2.

Sen­cha Archi­tect 2: What’s Changed, What’s New

A tool that works the way you do.

Click to watch our launch video

The foun­da­tional con­cept behind Archi­tect 2 is sim­ple: a visual app build­ing tool that cre­ates code as clean and well struc­tured as the code that a Lead Archi­tect at Sen­cha would write by hand. Archi­tect 2 is visual where it makes sense, but also gets out of your way when you need to dive into code.

This phi­los­o­phy led to the cre­ation of a tool that lets you iter­ate solu­tions with very low over­head and with instant visual feed­back; all assisted by inline doc­u­men­ta­tion and quick links to the API reference.

But the best part is that it’s a tool where exper­i­men­ta­tion is safe. All code gen­er­ated by Archi­tect is guar­an­teed to work out of the box. You can’t arrange com­po­nents in a way that will break the frame­works’ con­ven­tions. There’s also a wealth of new fea­tures that makes the expe­ri­ence of cre­at­ing apps a lot more enjoy­able and immediate.

The hub of all activ­ity: the Project Inspector

Sencha Architect project inspector

The Project Inspec­tor has been greatly enhanced to show views, con­trollers, mod­els, and stores all in one place, along with infor­ma­tion about the project’s struc­ture. All com­po­nents and their rela­tion­ships are right there, where you can see and ana­lyze them.

Frame­work Sup­port & Cre­ation Tools

Archi­tect can cre­ate appli­ca­tions for Ext JS 4 and Sen­cha Touch 2. The Tool­box has been improved dra­mat­i­cally to make the rich­ness of both frame­works more acces­si­ble. Cat­e­gories now make search­ing for a com­po­nent quicker, and it’s pos­si­ble to cre­ate new groups of com­po­nents for your per­sonal workflow.

Archi­tect also includes a built-in JavaScript edi­tor, so you can work on your code with­out switch­ing back and forth between dif­fer­ent tools, although it’s still easy to switch between Archi­tect and your favorite IDE.

In-line Doc­u­men­ta­tion

Now every com­po­nent, prop­erty and con­fig­u­ra­tion comes with handy inline doc­u­men­ta­tion, and if you need more, there are quick links to go deep into the API ref­er­ence. The doc­u­men­ta­tion is avail­able as a part of the main UI, and appears as tool-tips and hov­ers as you need it.

Source Control-Friendly File Format

Archi­tect 2 projects are eas­ier to man­age and track via source con­trol. The sin­gle file archive we had in Ext Designer 1 has been replaced by a file for each view, model, and store. This deci­sion was intended to make it eas­ier to work on a project where more than a sin­gle devel­oper is involved.

Native Mobile Pack­ag­ing & iOS Simulation

You can now pack­age appli­ca­tions for iOS and Android directly from Archi­tect 2. Using tech­nol­ogy we released with Sen­cha Touch 2, Archi­tect lets you take a fin­ished appli­ca­tion and get it ready for deploy­ment on a mobile device quickly and eas­ily. And if you’re on OS X and you have Xcode 4 installed, Archi­tect starts the iOS sim­u­la­tor for you and loads your appli­ca­tion automatically.


Click to explore the user inter­face of Sen­cha Archi­tect 2

A Bet­ter UX to Make Devel­op­ment Fun

Sev­eral weeks ago, we asked for vol­un­teers to help user-test our beta ver­sion. Thanks to their help and our exten­sive set of usabil­ity stud­ies, we were able to zero in on the biggest user expe­ri­ence issues and to design bet­ter solu­tions for com­monly per­formed tasks.

Here are just a few of the user expe­ri­ence improve­ments we made. We added a high­light for new com­po­nents that are added to the Project Inspec­tor: this helps you see where the com­po­nent is added in the hier­ar­chy. We added a tog­gle to the prop­erty panel that lets you switch between com­monly used con­fig­u­ra­tions vs. the com­pre­hen­sive set. We also enhanced our com­po­nent icons to improve read­abil­ity. These were just a few of a long list of detail improvements.

Count­less hours went into mak­ing Archi­tect 2 a beau­ti­ful and easy to use appli­ca­tion. User expe­ri­ence is never com­plete but we know you will notice right away how our new process has made the tool as easy to use as it is powerful.

We couldn’t have done it with­out you…

On top of our for­mal user stud­ies, we want to say thank you to our com­mu­nity for help­ing and guid­ing us with their con­stant feed­back: first with the pri­vate beta pro­gram for Sen­cha­Con 2011 atten­dees (it rocked to meet you in per­son in Austin!) to the later open beta. Your sug­ges­tions and ques­tions helped make Archi­tect 2 what it is today.

We also want to thank you for your patience and your incred­i­bly insight­ful com­ments, and we ask you to keep it up: Archi­tect 2 will be evolv­ing over the course of 2012 and we need your con­tin­ued sup­port and feed­back to make all the things we have dreamed dur­ing the last months a reality.

Keep ask­ing for new fea­tures, keep report­ing bugs, keep show­ing us your examples.


Sen­cha Archi­tect team mem­bers; (left to right) Aaron Con­ran, Luca Can­dela, David Foel­ber, Kather­ine Chu

Get­ting Started with Sen­cha Archi­tect 2

This ver­sion of Archi­tect ships with a sig­nif­i­cant num­ber of exam­ples for Ext JS 4 and Sen­cha Touch 2 alike. We have re-created a few of the frame­works’ demos in Archi­tect 2 includ­ing Geo­Congress and the Feed Reader, and it’s all avail­able from Architect’s prod­uct page (close to the bot­tom). Just unzip it and open the .xda files to see great exam­ples of entire applications.

The online doc­u­men­ta­tion is also a sig­nif­i­cant step for­ward. All our tech­ni­cal docs are now hosted online, just like the API docs, which makes them eas­ier to search and eas­ier to keep updated. While the docs are already much bet­ter, we are com­mit­ted to improve them and expand them sig­nif­i­cantly over time. Please let us know where you find the cur­rent doc­u­men­ta­tion lack­ing or unclear, and we will con­cen­trate our efforts where it’s most useful.

We also want to let you know that, if you have an exam­ple you are par­tic­u­larly proud of, and you want to share it with the com­mu­nity, sub­mit it to the dev team for inclu­sion with the set that comes with Archi­tect 2: if we like it, we’ll add it to the down­load­able pack­age and of course give you credit in the notes. It’s your chance to shine, don’t miss out on it!

Pric­ing & Availability

Indi­vid­ual copies of Sen­cha Archi­tect 2 cost $399, with dis­counts for 5 and 20 packs. If you are upgrad­ing from an old copy of Ext Designer 1, please read the fol­low­ing carefully:

  • If you bought Ext Designer 1.0 after Jan­u­ary 1st, 2012, you’re already enti­tled to Sen­cha Archi­tect 2! Your license will be sent shortly to your email address, but in case it doesn’t after a few days for any rea­son (typos, spam fil­ters, etc) please con­tactdesigner.upgrade@sencha.com and we will take care of every­thing for you.
  • If you pur­chased an Ext Designer 1.x license prior to Jan­u­ary 1st, 2012, you can upgrade to Archi­tect 2 for $279 in our online store.

Please note that Sen­cha Com­plete includes Archi­tect 2, and remains priced at $995. So, go ahead, buy Sen­cha Archi­tect 2 from the Sen­cha Store, or down­load the trial and share your expe­ri­ences with us!

Writ­ten by Luca Candela

via Intro­duc­ing Sen­cha Archi­tect 2: A Mas­sive Upgrade of Ext Designer | Blog | Sen­cha.

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

JavaScript, CSS, HTML Frameworks and Tools

Greg posted a very use­ful list of resources; One of the chal­lenges in the world of HTML/JavaScript/CSS app devel­op­ment is cob­bling together your kitchen sink of frame­works, tools and other tech­nolo­gies. When you start look­ing around, it feels like there is an end­less list of options, which is good and bad!  Recently, I’ve been gath­er­ing a list of what’s pop­u­lar these days and thought it might be use­ful for oth­ers to share. If you see any­thing obvi­ous miss­ing, please let me know.  Thanks to the fol­low­ing for help­ing me put together this list: Ray Cam­den, Andy Trice, Philip Wil­son, Christophe Coen­raets, Piotr Wal­czyszyn, and James Brown.

In no par­tic­u­lar order:

via Gregs Ram­blings.

Installing PHPUnit for PHP 5.3 on ZendServer

Zend­Server installs PHP CLI as part of the instal­la­tion, and, as is cus­tom­ary for PHP 4.3+, includes a PEAR installer. It’s a good idea to install PEAR before installing PHPUnit as per the rec­om­men­da­tion here.

  1. Open Zend\ZendServer\bin\go-pear.bat and change the line:
    %PHP_BIN% -d output_buffering=0 -d PEAR\go-pear.pharto (see PHAR Run­time Con­fig­u­ra­tion):%PHP_BIN% -d output_buffering=0 -d phar.require_hash=0 PEAR\go-pear.pharThis will stop the fatal error:phar...does not have a signatureas by default PHP will not process a PHAR archive with­out a signature.
  2. Run go-pear.bat

    For Win­dows 7, make sure you open the con­sole as an admin­is­tra­tor, or the installer won’t be able to cre­ate some fold­ers in the default install loca­tions. At the com­mand prompt enter:#cd \program files\zend\zendserver\bin
    # go-pear.bat
    and you should get some­thing like this (I selected the system-wide install and accepted the default locations):

via Installing PHPUnit for PHP 5.3 on Zend­Server | katsande.com.

ClamAV as a Validation Filter in Zend Framework

Matthew Set­ter writes a very inter­est­ing arti­cle; Ok, so you’re pretty com­fort­able with using the Zend Frame­work, specif­i­cally the use of Forms. Along with that, you have a good work­ing knowl­edge of how to com­bine a host of stan­dard val­ida­tors such as Cred­it­CardEmailAd­dressDb_RecordExists, and Hex, and stan­dard fil­terssuch as Compress/DecompressBase­NameEncrypt, and Real­Path. But what do you do when a sit­u­a­tion arises that’s out­side the scope of the pre-packaged val­ida­tors and filters?

Let’s say you want to guard against users upload­ing files that con­tain viruses, for exam­ple. You would have to write a cus­tom val­ida­tor that checks the uploads aren’t infected. Today I’ll show you how to do just that – how to write a new file val­i­da­tion fil­ter for Zend Frame­work that uses Cla­mAVto ensure uploaded files are virus-free.

Adding Cla­mAV Sup­port to PHP

First you’ll need to install Cla­mAV sup­port. I’m bas­ing this instal­la­tion pro­ce­dure around Linux, specif­i­cally Ubuntu. If you’re using another dis­tri­b­u­tion, you may need to adjust the com­mands accord­ingly. Unfor­tu­nately, if you’re using Win­dows how­ever, you’ll need to use a Linux-based Vir­tual Appli­ance or setup a vir­tual machine run­ning Linux to fol­low along since the php-clamav exten­sion doesn’t sup­port Win­dows as yet.

Full Story with Source » php­mas­ter.

Hackix #JS #sopastrike #SOPAblackout #sopa

HackIX joins #sopas­trike#SOPAblack­out #sopa and blacks out site on the 18th.

For more info  http://sopastrike.com/

Posted in Uncategorized by Danny Froberg. No Comments

Zend Server 5.6 is out

Kevin Schroeder writes; Zend Server 5.6 is out.  I’m actu­ally pretty stoked about this release.  Here’s a few rea­sons why.

  1. Zend Server CE now con­tains the full Zend Server stack.  Why do I find this excit­ing?  Because the upgrade path from CE to the full ver­sion is stu­pid easy.  That means you can try out all of the fea­tures in Zend Server and if you don’t want them, just let the license expire.  I call it a gate­way drug.  Seri­ously.  Get Stu­dio or PDT and try the deploy­ment fea­ture.  If you’re not using it you’ll ask your­self “why am I not doing this?”
  2. All of you Mac users can finally stop bitch­ing and com­plain­ing about the lack of Mac sup­port.  We don’t (and prob­a­bly won’t) sup­port Mac for pro­duc­tion (does any­one besides Apple actu­ally use their server prod­ucts in pro­duc­tion?) but for dev work you now get the full stack on your Mac.  This is not GA yet but will be later on.  If you want a pre­view release you can go to http://forums.zend.com/viewtopic.php?f=8&t=26873 .
  3. Fault tol­er­ance in the Job Queue through MySQL clus­ter­ing.  In clus­tered envi­ron­ments job queue infor­ma­tion has moved from local stor­age to remote MySQL stor­age.  So you can have a sin­gle MySQL server sit­ting there, a clus­tered setup or RDS or some other cloud-based DB, it doesn’t mat­ter.  If it can be accessed using the MySQL dri­vers then it can be used by the new Job Queue.

via ESchrade — Pure PHP Good­ness.

How To Take Screenshot on the iPad2

If you are see­ing some­thing inter­est­ing on the iPad screen that you would want to cap­ture. Screen­shot is quite use­ful, espe­cially if you have an error on your device and you want to cap­ture an image so that later you could show it to a sup­port tech and they could assist you in fix­ing the issue.

Heres how:

1. While you are look­ing at the screen press Sleep/Wake + Home but­ton and quickly let go of the buttons.

You will see the screen quickly flashes indi­cat­ing that it has taken the screen­shoot. Your cap­ture should now be placed in the Cam­era Roll album. To view the image go into the album and open it up.

Once you have the image you could email it.

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

Connecting to PHPCloud.com through Zend Studio 9

PHPCloud.com is the land­ing page for our new cloud offer­ing.  Using the Zend Appli­ca­tion Fab­ric you can build your appli­ca­tions in the same envi­ron­ment as you will be deploy­ing your apps to.  The appli­ca­tion is built on my.phpcloud.com and you can then deploy it onto any plat­form where the Fab­ric is supported.

But how do you get started?  Phpcloud.com has been built in a way where you can con­nect with any IDE.  With Zend Stu­dio 9 that con­nec­tiv­ity has been built directly in to the IDE.

Get­ting started is actu­ally quite easy.

via Read here for the full details.

Tags: , ,
Posted in Cloud Development PHP Zend Studio by Danny Froberg. No Comments

How to create custom MouseEvent.CLICK event in AS3 (pass parameters to function)?

Matt W answers;
Take advan­tage of the dynamic func­tion con­struc­tion in AS3.


private function myCallbackFunction(e:Event, parameter:String):void
{
     //voila, here's your parameter
}

private function addArguments(method:Function, additionalArguments:Array):Function
{
     return function(event:Event):void {method.apply(null, [event].concat(additionalArguments));}
}

    var parameter:String = "A sentence I want to pass along";
    movieClip.addEventListener(Event.COMPLETE, addArguments(myCallbackFunction, [parameter] ) );
Tags: , ,
Posted in AIR Development Flash Flex by Danny Froberg. No Comments

Creating a Windows AIR Native Extension with Eclipse

Nick Kwiatkowski cre­ated a few very inter­est­ing posts with video tuto­ri­als, he writes; The sec­ond I heard about Adobe giv­ing us the abil­ity to cre­ate our own exten­sions to the Flash Plat­form in AIR 3.0, I was smit­ten. It was finally a way that we could add our own fea­tures and do the things that were high pri­or­i­ties on our lists, but not on Adobe’s. I knew I was look­ing for fea­tures that were one-offs (how many peo­ple today really need access to the COM ports), but they were forc­ing me to do all sorts of weird workarounds like launch­ing proxy appli­ca­tions to do seem­ingly sim­ple tasks.

AIR 3.0 got released a few weeks ago and I’ve jumped in head first into cre­at­ing some ANEs (AIR Native Exten­sions). For those of you who don’t know, ANEs are pack­aged exten­sions that con­tain operating-system spe­cific code (DLLs for Win­dows, Libraries for MacOS, Java classes for Android and Objective-C for iOS), that allow you to do things that the Flash Player wasn’t able to do.

Unfor­tu­nately, Adobe assumed that if you were devel­op­ing DLLs for Win­dows, you were going to be using Visual Stu­dio and noth­ing more. This didn’t make a whole lot of sense in my mind as they’ve been lever­ag­ing Eclipse for all of their tool­ing, and Eclipse does offer some great C/C++ addins. Now, that being said, Visual Stu­dio is by far the more feature-full and hands-down the best edi­tor for enabling these kinds of work­flows on Win­dows. It is, how­ever, very costly and even though Microsoft offers a free ver­sions, it takes over your com­puter by installing debug ver­sions of most of Microsoft’s shared libraries mak­ing your com­puter slower and more crash prone.

I wanted to use Eclipse’s CDT addin with the stan­dard GCC tool­ing that is avail­able on pretty much every oper­at­ing sys­tem. By using GCC, I was able to make very portable code that with min­i­mal effort was able to com­pile on all three of the major OSs (Win­dows, Mac, Linux). Adobe’s doc­u­men­ta­tion was lit­tle help in get­ting this going (even if you were cod­ing in Visual Stu­dio, there is very lit­tle guid­ance on how to get things setup). I do have to note that with my setup there is one dis­tinct dis­ad­van­tage — the lack of abil­ity to debug the DLL when it is launched from AIR. You will have to write your own C/C++ har­ness to do test­ing on your code in order to test it. If you use the Visual Stu­dio tool­ing, you CAN debug any DLL while it is run­ning (this is why Microsoft replaces the shared libraries on your sys­tem to allow that debugging).

I’ve cre­ated a four part video series doc­u­ment­ing how to get going cre­at­ing ANEs. Part 1 cov­ers set­ting up your envi­ron­ment, includ­ing installing CDT, the com­piler, and get­ting Eclipse setup to do your pro­gram­ming. Part 2 cov­ers actu­ally cod­ing the C/C++ code for your Win­dows DLL. Part 3 cov­ers cre­at­ing your ANE, and pack­ing up all the stuff needed to make it work. And Part 4 cov­ers how to use your new ANE in an AIR project.

Watch the Video » Part 1 « QueT­wos Blog.

Tags: , , ,
Posted in AIR Development Flash Flex Videos by Danny Froberg. No Comments

Drag-and-Drop in Flex 4

UPDATE: I have another Drag-and-Drop Revis­ited post that cov­ers even more drag-and-drop func­tion­al­ity avail­able in Flex 4.

The Flex 4 gods were kind to us devel­op­ers when they made the great deci­sion to leave the cus­tom drag-and-drop sup­port unchanged. We just do what we’ve always done: detect the user is try­ing to drag some­thing via mouseDown or mouseMove and then add both dragEnter and dragDrop event han­dlers to the drop tar­get. So there is noth­ing in this post that’s not basi­cally iden­ti­cal to Flex 3, except the cool­ness of FXG (which you can eas­ily mimic with Degrafa in Flex 3).

Sim­ple Drag-and-Drop

via Drag-and-Drop in Flex 4 « Sat­urn­boy.

Tags: , , ,
Posted in AIR Development Flash Flex by Danny Froberg. No Comments

Splash screen with FXG in Mobile applications with Flash Builder for PHP

ahillman3 on Stack Over­flow wrote this (and won my hero of the day award); OK, the pri­mary focus for your solu­tion is the pre­loader attribute on a mobile appli­ca­tion. See the preloader=“CustomSplashScreen” below:

< ?xml version="1.0" encoding="utf-8"?>
xmlns:s="library://ns.adobe.com/flex/spark"
firstView="views.FXGSplashHomeView"
preloader="CustomSplashScreen"
splashScreenMinimumDisplayTime="3000"
applicationDPI="160">


The Cus­tom­Splash­Screen extends and over­rides the spark.preloaders.SplashScreen class, and the getIm­age­Class func­tion.

package
{

import mx.core.DPIClassification;
import mx.core.mx_internal;

import spark.preloaders.SplashScreen;

use name­space mx_internal;
pub­lic class Cus­tom­Splash­Screen extends SplashScreen

{
pub­lic func­tion Cus­tom­Splash­Screen()
{
super();
}

over­ride mx_internal func­tion getImageClass(dpi:Number, aspectRatio:String):Class
{
return Class(splash);
}
}
}

The splash in the return Class(splash), is a sim­ple fxg file, like so:

< ?xml version="1.0" encoding="UTF-8"?>
xmlns:d="http://ns.adobe.com/fxg/2008/dt"
xmlns:fc="http://ns.adobe.com/flashcatalyst/2009"
version="2.0">





That’s all there is to it. Have fun!

– Allen

via .

Flex wrappers for MadComponents

Daniel Free­man writes; I’ve had feed­back from a few devel­op­ers want­ing a way to com­bine Mad­Com­po­nents with Flash Builder 4.5 for mobile.  I intended Mad­Com­po­nents as a ligh­weight alter­na­tive to using the Flex frame­work.  So while I don’t really like the idea of mix­ing them – it’s cer­tainly pos­si­ble to incor­po­rate Mad­Com­po­nents within an MXML lay­out.  All it takes is a few cus­tom com­po­nent wrappers.

Note: I’ve now put the code for these wrap­pers into the SVN code repos­i­tory.

Note: I’ve now put the code for these wrap­pers into the SVN code repository.

via MobileAp­pDev.

MadComponents AMF Service Test Drive for Mobile

Daniel Free­man writes; In this final Mad­Com­po­nents tuto­r­ial we’re going to look at the third and final Flash Builder 4.5 tuto­r­ial (from here), and do it the Mad­Com­po­nents way.  Adobe’s Flex Test Drive for Mobile: Build a mobile appli­ca­tion in an hour, takes you through build­ing an AMF web ser­vice, and then build­ing a mobile client appli­ca­tion that con­nects to that ser­vice.  We’re going to build the same appli­ca­tion using MadComponents.

AMF is a binary for­mat used to seri­alise Action­Script objects.  A binary AMF packet is usu­ally sig­nif­i­cantly smaller than REST XML or SOAP packet.  Hence AMF ser­vices are typ­i­cally much faster.

This tuto­r­ial assumes that you have some exper­tise in build­ing web ser­vices, using PHP, Cold­fu­sion, or Java.  But if you’d rather do a tuto­r­ial where the web ser­vice already exists, then have a go at build­ing a twit­ter client.

We rec­om­mend that you first take a look at the first six parts of this tuto­r­ial series, which will bring you up-to-speed with using MadComponents.

Read the entire tuto­r­ial at  Mad­Com­po­nents AMF Ser­vice Test Drive for Mobile « MobileAp­pDev.

Zend AMF Authentication & Authorization

dkozar evolved a work­ing method to Authen­ti­cate and Autho­rize a Flex based app datas ser­vice call using Zend AMF, he writes;

I’ve been strug­gling with it, and fig­ured it all out — so, per­haps it could help others.

The authen­ti­ca­tion is called on the server only if cre­den­tials sup­plied from the client (via the remote pro­ce­dure call head­ers). This snip­pet illus­trates the setup of cus­tom auth (these are the last 6 lines of gateway.php script):

// Handle request
$auth = new My_Amf_Auth(); // authentication
$server->setAuth($auth);
$acl = new Zend_Acl(); // authorization
$server->setAcl($acl);
echo $server->handle();

Now, your cus­tom auth should extend Zend_Amf_Auth_Abstract. Since I want to authen­ti­cate users from a data­base, I bring the Zend_Auth_Adapter_DbTable to play. But since I can­not extend both Zend_Amf_Auth_Abstract and Zend_Auth_Adapter_DbTable, I use a com­po­si­tion:

< ?php
require_once ('Zend/Amf/Auth/Abstract.php');

/**
* AMF auth class by Danko Kozar, dankokozar.com
* @author dkozar
*
*/
class My_Amf_Auth extends Zend_Amf_Auth_Abstract {

func­tion __construct() {

}

pub­lic func­tion authenticate() {

$adapter = My_Db_Adapter::getInstance();
$adapter->setIdentity($this->_username);
$adapter->setCredential($this->_password);

// the adapter call
// you can wrap it into try.. catch and process DB con­nec­tion errors
$result = Zend_Auth::getInstance()->authenticate($adapter);

return $result;
}
}

Here’s the adapter class:

< ?php
/**
* DB table adapter auth class for AMF by Danko Kozar, dankokozar.com
* @author dkozar
* Singleton
*/
class My_Db_Adapter extends Zend_Auth_Adapter_DbTable {

pro­tected sta­tic $_instance = null;

/**
* pri­vate!
* @param My_Db_Adapter $adapter
*/
pub­lic func­tion __construct(Zend_Db_Adapter_Abstract $adapter = null) {

if (!$adapter)
$adapter = new Zend_Db_Adapter_Mysqli(
array(
‘dbname’ => ‘test’,
‘user­name’ => ‘root’,
‘pass­word’ => ”)
);

parent::__construct($adapter);

$this
->setTableName(‘users’)
->setIdentityColumn(‘username’)
->setCredentialColumn(‘password’)
;

// just for test­ing
// $this
// ->setIdentity(‘username’)
// ->setCredential(‘password’)
// ;
}

/**
* @return My_Db_Adapter
*/
pub­lic sta­tic func­tion getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}

pub­lic func­tion authenticate() {

$_authResult = parent::authenticate();

// NOTE: The point is that $result->_identity is an OBJECT (of type std­Class), NOT string
// with Zend_Auth_Adapter_DbTable it is inter­nally accom­plished by call­ing its getRe­sul­tRowOb­ject() method
// It con­structs the std­Class with prop­er­ties named after table attributes

// $user = new std­Class();
// $user->role = “admin­is­tra­tor”;
// $user->username = $_authResult->getIdentity();

$iden­tity = $this->getResultRowObject();

$result = new Zend_Auth_Result($_authResult->getCode(), $identity);

return $result;
}
}

MyService.php class. Here it is:


< ?php
/**
* PHP service class with authorization
* by Danko Kozar, dankokozar.com
* @author dkozar
*
*/
class MyService
{
/**
* from zend docs:
* If the ACL object is set, and the class being called defines initAcl() method,
* this method will be called with the ACL object as an argument.
* This method can create additional ACL rules and return TRUE,
* or return FALSE if no access control is required for this class.
*
* @param Zend_Acl $acl
* @return boolean
*/
public function initAcl($acl)
{
$acl->addRole(new Zend_Acl_Role("administrator"));
$acl->addRole(new Zend_Acl_Role("user"));

//acl “allow” method takes 3 para­me­ters (role, resource — class name, priv­i­leges — it’s func­tion name in this class)

// admin­is­tra­tor
$acl->allow(‘administrator’, ‘MySer­vice’, ‘hel­loWorld’);
$acl->allow(‘administrator’, ‘MySer­vice’, ‘getData’);

// user
$acl->allow(‘user’, ‘MySer­vice’, ‘hel­loWorld’);
$acl->deny(‘user’, ‘MySer­vice’, ‘getData’);

//returning true to sig­nal that we want to check priv­i­leges before access­ing meth­ods of this class
//in my tests if we don’t return any­thing it will treat it like we will return false so bet­ter return true or false
//your inten­tions will be clear
return true;
}

/**
* Hello world method
*/
pub­lic func­tion hel­loWorld(){
return “Hello world from MySer­vice ser­vice”;
}

/**
*
* Returns data
* @return [int]
*/
func­tion get­Data()
{
$arr = array(1, 2, 3);
return $arr;
}
}
?>

Note that the autho­riza­tion is being built dynam­i­cally inside the ini­tAcl method.

On the Flex side I have an auto-generated class (MySer­vice) which extends another auto-generated class (_Super_MyService).

The point is that the outer one is auto-generated only once (ini­tially), and you can mod­ify it, with­out wor­ry­ing to be over­writ­ten on ser­vice regeneration.

There’s a pro­tected prop­erty _serviceControl (which is of type Remo­teOb­ject) which could be tweaked if needed.

I’m tweak­ing it by of set­ting the end­point (with string read from a client side con­fig in preIni­tial­ize­Ser­vice() method). Plus, I’m adding 2 more meth­ods, which expose set­Cre­den­tials and setRemote­Cre­den­tials meth­ods of _serviceControl, so I can acces it from my code.


package services.myservice
{
public class MyService extends _Super_MyService
{
/**
* Override super.init() to provide any initialization customization if needed.
*/
protected override function preInitializeService():void
{
super.preInitializeService();

// Ini­tial­iza­tion cus­tomiza­tion goes here
_serviceControl.endpoint = “http://localhost/myapp/gateway.php”;
}

pub­lic func­tion setCredentials(username:String, password:String, charset:String=null):void
{
_serviceControl.setCredentials(username, pass­word, charset);
}

pub­lic func­tion setRemoteCredentials(username:String, password:String, charset:String=null):void
{
_serviceControl.setRemoteCredentials(username, pass­word, charset);
}
}
}


So, before call­ing MySer­vice meth­ods, I’m set­ting the cre­den­tials with set­Cre­den­tials() method and this runs the authen­ti­ca­tion on the PHP side:


private var service:MyService;
....
service = new MyService(); // ServiceLocator.getInstance().getHTTPService("presetLoader");
service.setCredentials("user1", "pass1");
var token:AsyncToken = service.getData();

The authen­ti­ca­tion via Zend_Amf_Server is, by the way, OPTIONAL! Mean­ing, with no cre­den­tials sup­plied, Zend_Amf_Server will NOT RUN IT. Thus you should rely on Zend_Acl (e.g. roles) to so your per­mis­sions and security!

Finally, here’s the MySQL DB table I’ve been using for authen­ti­ca­tion:

--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(32) DEFAULT NULL,
`role` varchar(45) DEFAULT NULL,
`firstname` varchar(50) DEFAULT NULL,
`lastname` varchar(50) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;


– Dump­ing data for table ‘users‘

INSERT INTO ‘users‘ (‘id‘, ‘user­name‘, ‘pass­word‘, ‘role‘, ‘first­name‘, ‘last­name‘, ‘email‘) VALUES
(1, ‘user1’, ‘pass1’, ‘admin­is­tra­tor’, ‘Danko’, ‘Kozar’, NULL);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Cheers!
Danko

Adobe Forums

Get Adobe Flash player