Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
SERVER SIDE BREAKOUT                             phpWednesday, November 2, 11
5 YEARS AGO (2006)                                 PHP version 5.2.0                                native JSON supportWed...
MODERN USAGE                               77% of all websitesWednesday, November 2, 11
MODERN USAGE                                MiddlewareWednesday, November 2, 11
INTERFACES                                 REST                               Ext.DirectWednesday, November 2, 11
REST                                 Great for APIs                                 Cross-domain                          ...
REST                            proxy: {                                       type: rest,                                ...
REST                            Extra server setup may be needed                             Difficult concurrency (bufferi...
EXT.DIRECT                                         OOB buffering                                         Effortless setup ...
EXT.DIRECT                            Ext.ns("Ext.app");                            Ext.app.REMOTING_API = {              ...
EXT.DIRECT                            proxy: {                                       type: direct,                        ...
EXT.DIRECT                            proxy: {                                       type: direct,                        ...
EXT.DIRECT                            Not cross-domain friendly                            Needs a router (s-s stack)     ...
SAMPLE USAGE                            RESTFUL INTERFACEWednesday, November 2, 11
EXT.DIRECTWednesday, November 2, 11
JSON VS. JSONP            {                                 Ext.util.JSONP.callback1({                ‘name’ : ‘John’,    ...
JSON VS. JSONP                            $callback = $_REQUEST[“callback”];                            $select = $db->sel...
BIG APPS                              Big appsWednesday, November 2, 11
BIG APPS                                      MVC                            Fat model - thin controllerWednesday, Novembe...
BIG APPS                             AbstractingWednesday, November 2, 11
LOADING APP COMPONENTS                                       Ext.Loader                            Sencha command / jsbuil...
ENVIRONMENT                                ApacheWednesday, November 2, 11
ENVIRONMENT                                    Apache                                       +                             ...
ENVIRONMENT                            SetEnv APP_ENV "development"                               $_SERVER[APP_ENV])Wednes...
ENVIRONMENT                                     MIME handling                            JSONP : application/javascript   ...
ENVIRONMENT                               File structureWednesday, November 2, 11
Wednesday, November 2, 11
ENVIRONMENT                               DB layoutWednesday, November 2, 11
TRADITIONAL RELATIONAL                    MODELWednesday, November 2, 11
CENTRALIZED RELATIONAL                    MODELWednesday, November 2, 11
Wednesday, November 2, 11
FIREPHP                            $logger = new Zend_Log();                            $writer = new Zend_Log_Writer_Fire...
FIREPHP             $select = $ssoDb->select() ->from(products);             $logger->log($select->__toString(), Zend_Log:...
BAD IDEAS                          Enclose entire class in a single try/catch block                        Use sleep to wa...
BAD IDEAS                        Using self-made cyphers for encryption              Clear text passwords, CC info, person...
Grgur Grisogono                                @ggrgurWednesday, November 2, 11
Upcoming SlideShare
Loading in …5
×

PHP Server-side Breakout

4,213 views

Published on

Understand the approaches and best practices for integrating client side applications - both desktop and mobile - with various server-side technologies.

Grgur Grisogono, Modus Create, is a JavaScript lover focused on Ext JS and Sencha Touch. Exploiting the passion as a Sr JavaScript developer at Modus Create. Grgur has architected and developed market leading national, regional, and local development web apps used by 6 governments, 600+ municipalities, and government departments in several European countries. This year, he has organized Sourc{, a hugely successful developer oriented mobile and desktop web app conference, sponsored by Sencha.

Published in: Technology
  • it is very helpful slide...my many problems solved...
    now I know what directory structure to use for scalable apps, and some other things.
    Thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

PHP Server-side Breakout

  1. 1. SERVER SIDE BREAKOUT phpWednesday, November 2, 11
  2. 2. 5 YEARS AGO (2006) PHP version 5.2.0 native JSON supportWednesday, November 2, 11
  3. 3. MODERN USAGE 77% of all websitesWednesday, November 2, 11
  4. 4. MODERN USAGE MiddlewareWednesday, November 2, 11
  5. 5. INTERFACES REST Ext.DirectWednesday, November 2, 11
  6. 6. REST Great for APIs Cross-domain Status code messages One setup for all purposes echo $jsonWednesday, November 2, 11
  7. 7. REST proxy: { type: rest, url: api/users }Wednesday, November 2, 11
  8. 8. REST Extra server setup may be needed Difficult concurrency (buffering) Requires access to php://inputWednesday, November 2, 11
  9. 9. EXT.DIRECT OOB buffering Effortless setup API integration (RPC) Easier RPC role-based method distribution return $arrayWednesday, November 2, 11
  10. 10. EXT.DIRECT Ext.ns("Ext.app"); Ext.app.REMOTING_API = { "url":"php/router.php", "type":"remoting", "actions":{ "TestAction":[ {"name":"doEcho","len":1} ] } };Wednesday, November 2, 11
  11. 11. EXT.DIRECT proxy: { type: direct, directFn: doEcho }Wednesday, November 2, 11
  12. 12. EXT.DIRECT proxy: { type: direct, api: { create : Rpc.users.Add, read : Rpc.users.List, update : Rpc.users.Update, delete : Rpc.users.Delete }Wednesday, November 2, 11
  13. 13. EXT.DIRECT Not cross-domain friendly Needs a router (s-s stack) No file uploading Exception stops executionWednesday, November 2, 11
  14. 14. SAMPLE USAGE RESTFUL INTERFACEWednesday, November 2, 11
  15. 15. EXT.DIRECTWednesday, November 2, 11
  16. 16. JSON VS. JSONP { Ext.util.JSONP.callback1({ ‘name’ : ‘John’, ‘name’ : ‘John’, ‘email’ : ‘john@smith.com, ‘email’ : ‘john@smith.com, ‘dob‘ : 19781213, ‘dob‘ : 19781213, ‘kids‘ : [‘Sarah’, ‘Norah’] ‘kids‘ : [‘Sarah’, ‘Norah’] } })Wednesday, November 2, 11
  17. 17. JSON VS. JSONP $callback = $_REQUEST[“callback”]; $select = $db->select()->from(products); $stmt = $select->query(); $result = $stmt->fetchAll(); $output = json_encode($result); if ($callback) { header(Content-Type: text/javascript); echo $callback . ( . $output . );; } else { header(Content-Type: application/x-json); echo $output; }Wednesday, November 2, 11
  18. 18. BIG APPS Big appsWednesday, November 2, 11
  19. 19. BIG APPS MVC Fat model - thin controllerWednesday, November 2, 11
  20. 20. BIG APPS AbstractingWednesday, November 2, 11
  21. 21. LOADING APP COMPONENTS Ext.Loader Sencha command / jsbuilder on the flyWednesday, November 2, 11
  22. 22. ENVIRONMENT ApacheWednesday, November 2, 11
  23. 23. ENVIRONMENT Apache + Nginx reverse proxyWednesday, November 2, 11
  24. 24. ENVIRONMENT SetEnv APP_ENV "development" $_SERVER[APP_ENV])Wednesday, November 2, 11
  25. 25. ENVIRONMENT MIME handling JSONP : application/javascript JSON : application/json appcache : text/cache-manifestWednesday, November 2, 11
  26. 26. ENVIRONMENT File structureWednesday, November 2, 11
  27. 27. Wednesday, November 2, 11
  28. 28. ENVIRONMENT DB layoutWednesday, November 2, 11
  29. 29. TRADITIONAL RELATIONAL MODELWednesday, November 2, 11
  30. 30. CENTRALIZED RELATIONAL MODELWednesday, November 2, 11
  31. 31. Wednesday, November 2, 11
  32. 32. FIREPHP $logger = new Zend_Log(); $writer = new Zend_Log_Writer_Firebug(); $logger->addWriter($writer); Zend_Registry::set(logger,$logger);Wednesday, November 2, 11
  33. 33. FIREPHP $select = $ssoDb->select() ->from(products); $logger->log($select->__toString(), Zend_Log::INFO); $logger->log($data, Zend_Log::INFO);Wednesday, November 2, 11
  34. 34. BAD IDEAS Enclose entire class in a single try/catch block Use sleep to wait for another task/thread to finish Setting global vars to return multiple values Altering framework files Performing DB aggregate operations in PHP Keeping connections openWednesday, November 2, 11
  35. 35. BAD IDEAS Using self-made cyphers for encryption Clear text passwords, CC info, personal details (inc names) Not checking for user credentials on every request Trusting client-side input validation Constructing sql queries by using concatenation Not using DB transactions on multiple changes Direct access to files for downloadWednesday, November 2, 11
  36. 36. Grgur Grisogono @ggrgurWednesday, November 2, 11

×