8. About self::$me Past: Programming/Sys Admin Current: Technology Evangelist/Author/Composer @kpschrade
9. Assumptions (rightly or wrongly) You know Flash You know about Flash Builder You have heard about Flash Builder for PHP You don’t know, or think you know, PHP You do not know Zend Framework
10. PHP is written in C and written for the web If you wonder why PHP does something a certain way the answer will probably be found in one of those two places
11. PHP Dynamically typed language (not un-typed/typeless) Variable values may be modified base on context $data = “1two3four5”; can be worked upon as a string, integer, float or boolean. Isn’t that kind of weird? Nope. See any integers? GET /?data=1two3four5&data2=1 HTTP/1.1 Host: corp Connection: keep-alive Content-Length: 0 User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
13. Language Features Object Oriented Programming or Procedural (or both) Namespaces Exceptions Reflection A dozen protocols or wrappers accessible to FS ops Wide range of APIs Web Services XML Processing (DOM & Expat) Databases Huge number of frameworks Huge number of applications
14.
15. Objects/Classes Namespace Separator is br />Namespace Declaration (PHP 5.3+) Extending a class Class Properties Magic/reserved method names Static Context No return type Calling a static element
16. Application Structure/Behavior (Autoloading) Class files need to be explicitly require()d unless you use an autoloader Use an autoloader Registered with the __autoload() method If a class does not exist in the current request, it will be called to load the class file Will equal “MyClass1”
18. Application Structure/Behavior (Autoloading) Mapping class names to files Class files must be in the include_path Both map to Zend/Lib/MyClass.php PHP 5 Pseudo namespaces PHP 5.3+ Namespaces
19. Database Access Extensions (mysql, mysqli, sqlsrv, oci8, etc.) PDO (pdo_mysql, pdo_sqlite, pdo_ibm, etc.) Don’t create a DB connection in your general purpose classes Use dependency injection Use a singleton/factory/adapter
20. Deployment PHP does not have a “required” binary distribution format like SWF, APK, IPA, etc. Zend Server 5.5 beta has a new deployment feature w/ package format Application is deployed as source code Deployed source files should generally be kept out of the public document root Configuration files should definitely be kept out of the document root
25. Zend Framework PHP-based framework managed by Zend Technologies Framework/Component library DB access/modeling Service layer Authentication/ACLs MVC A TON more Used as the supported mechanism for access PHP-based services in Flash Builder for PHP
26. Action Message Format Protocol for serializing objects to/from a Flash player Supports strong typing of data Support in multiple languages Support for any binary transport that ActionScript supports Two versions AMF0 AMF3
27. Zend_Amf A Zend Framework based component to facilitate connections to Flash Two mechanisms Direct Serializer Used for non-service endpoints (SMTP, Stomp, File System) Generally not what you will use Zend_Amf_Server Used for service-based endpoints Manages calls to service classes similar to MVC Generally what you will use
28. Direct Serializer Create an object Create the output stream Create the serializer Write the object Get the output from the stream Weird, but required
29. Reading the (PHP) serialized object Not just for PHP! Regular binary data Magic!
30. PHP Application Building a Service Oriented Architecture Flash Application Service Call 1 Service Call 3 HTTP Gateway Service Class 1 Service Class 2 Service Class 3 Service Class 4
31. Steps Create value object classes to represent data Use PHPDoc to document data types Create a service class to provide access Use PHPDoc to document return types Create the service in Flash Builder Drag-n-drop services onto bindable components or create them directly using ActionScript Profit!
32. A Simple Architecture Libraries and Value Objects* Document Root Services to expose */services is not in the include_path, otherwise value objects would go there
33. Integrating into your own application Define service classes Bootstrap your application Call Zend_Amf_Server
34. Handling authentication Implements Zend_Auth_Adapter_Interface Create a simple auth adapter Generic identity class Add to gateway Add role to server ACL Allow only the logged in role Identity object requires “role” property
36. Method-level ACLs Add method-specific resource Tell Zend_Amf_Server that the ACL needs to be checked against Explicitly allow for guests Already allowed for logged in users
37. Demo : Creating and binding a PHP endpoint (slides would mean endless screen shots that would result in… well… this: