Transcript
Page 1: Zend Server: Not just a PHP stack

ZEND SERVER: NOT JUST A PHP STACK

Page 2: Zend Server: Not just a PHP stack

JEROEN VAN DIJK

Page 3: Zend Server: Not just a PHP stack

@JRVANDIJK

Page 4: Zend Server: Not just a PHP stack

BOARD MEMBER

Page 5: Zend Server: Not just a PHP stack
Page 6: Zend Server: Not just a PHP stack

NETHERLANDS

UNITED KINGDOM

BELGIUM

GERMANY

AMSTERDAM

Page 7: Zend Server: Not just a PHP stack

NETHERLANDS

UNITED KINGDOM

BELGIUM

GERMANY

AMSTERDAM

NOT AMSTERDAM

Page 8: Zend Server: Not just a PHP stack

NETHERLANDS

UNITED KINGDOM

BELGIUM

GERMANY

AMERSFOORT

Page 9: Zend Server: Not just a PHP stack

ENRISE HEADQUARTERS

Page 10: Zend Server: Not just a PHP stack

SERVING PHP APPS

Page 11: Zend Server: Not just a PHP stack

WHO’S DOING MANUAL COMPILE OF PHP?

Page 12: Zend Server: Not just a PHP stack

WHO’S USING STOCK DISTRO VERSIONS?

Page 13: Zend Server: Not just a PHP stack

IN PRODUCTION?

WHO’S USING OTHER STACKS?

Page 14: Zend Server: Not just a PHP stack

WRITING YOUR OWN CODE

Page 15: Zend Server: Not just a PHP stack

COMPOSING JSON FILES

Page 16: Zend Server: Not just a PHP stack
Page 17: Zend Server: Not just a PHP stack

GUZZLE

TWIG

MONOLOG

SWIFTMAILER

DOCTRINE

PHPUNIT

ROUTING

YAML

CODECEPTION

EVENTMANAGER

Page 18: Zend Server: Not just a PHP stack

SHIP & DEPLOY

Page 19: Zend Server: Not just a PHP stack

MONITORING

Page 20: Zend Server: Not just a PHP stack

<?php require_once __DIR__ . '/../vendor/autoload.php';

$app = new Silex\Application();

$app->get('/slowrequest', function() use($app) { sleep(5);

return $app->json(array('That was slow')); });

$app->run();

SIMPLE SILEX EXAMPLE

Page 21: Zend Server: Not just a PHP stack

TRIGGERED EVENTS

Page 22: Zend Server: Not just a PHP stack

BASIC CONFIG

Page 23: Zend Server: Not just a PHP stack

THRESHOLD CONFIG

Page 24: Zend Server: Not just a PHP stack

$app = new Silex\Application();

$app->get('/slowrequest', function() use($app) { if (function_exists('zend_monitor_custom_event')) { zend_monitor_custom_event( 'Internal Application Error', 'your error message', array( 'trace' => 'this went wrong' ) ); }

return $app->json(array('That was slow')); });

LOGGING A CUSTOM EVENT

Page 25: Zend Server: Not just a PHP stack

1

ALTERNATIVE: NEW RELIC

Page 26: Zend Server: Not just a PHP stack

CODETRACING & PROFILING

Page 27: Zend Server: Not just a PHP stack

DETAILED INSPECTION

Page 28: Zend Server: Not just a PHP stack

MY PREFERRED METHOD

Page 29: Zend Server: Not just a PHP stack

WARNING!

ENABLED FOR LIMITED TIME

MAXIMUM CODETRACING FILE SIZE

GREAT POWER == GREAT RESPONSIBILITY

Page 30: Zend Server: Not just a PHP stack

2

ALTERNATIVE: XHPROF

Page 31: Zend Server: Not just a PHP stack

DEBUGGING

Page 32: Zend Server: Not just a PHP stack

VAR_DUMP DRIVEN DEVELOPMENT

VDD

Page 33: Zend Server: Not just a PHP stack

VAR_DUMP DRIVEN DEVELOPMENT

VDD

Page 34: Zend Server: Not just a PHP stack

DEBUGGER COMMUNICATION

& DEBUG_PORT=10137 & DEBUG_HOST=172.17.0.199,127.0.0.1

LOCALHOST:20080

Page 35: Zend Server: Not just a PHP stack

DEBUGGER CONFIG

Page 36: Zend Server: Not just a PHP stack

§ Chrome zDebug extension

§ Jetbrains bookmarklets § https://www.jetbrains.com/phpstorm/marklets/

§ Zend debugger toolbar

ENABLE BROWSER DEBUGGING

Page 37: Zend Server: Not just a PHP stack

DEBUG SESSION

Page 38: Zend Server: Not just a PHP stack

DEBUG LOGGED EVENT

Page 39: Zend Server: Not just a PHP stack

REMOTE DEBUGGING

SSH -L <USER> -R 10137:LOCALHOST:10137 <HOST>

Page 40: Zend Server: Not just a PHP stack

3

ALTERNATIVE: XDEBUG

Page 41: Zend Server: Not just a PHP stack

Z-RAY

Page 42: Zend Server: Not just a PHP stack

§ WordPress debug bar

§ Zend Framework 2 developer tools

§ Symfony 2 web profiler

§ Yii debug toolbar

§ ….

§ ….

DEBUG TOOLBARS

Page 43: Zend Server: Not just a PHP stack

§ WordPress debug bar

§ Zend Framework 2 developer tools

§ Symfony 2 web profiler

§ Yii debug toolbar

§ ….

§ ….

DEBUG TOOLBARS

Page 44: Zend Server: Not just a PHP stack

Z-RAY TOOLBAR

Page 45: Zend Server: Not just a PHP stack

Z-RAY TOOLBAR

Page 46: Zend Server: Not just a PHP stack

Z-RAY TOOLS IN ADMIN

Page 47: Zend Server: Not just a PHP stack

Z-RAY TOOLS IN ADMIN

Page 48: Zend Server: Not just a PHP stack

4

ALTERNATIVE: ???

Page 49: Zend Server: Not just a PHP stack

ONE MORE THING

Page 50: Zend Server: Not just a PHP stack

THE EASY WAY

QUEUEING

Page 51: Zend Server: Not just a PHP stack

$app->get('/slowrequest', function() use($app) { $queue = new ZendJobQueue(); $queue->createHttpJob('/sendemail', array( 'email'=>'[email protected]'), array('name'=>'Send email') ); return $app->json(array('That wasn\'t slow')); });

$app->post('/sendemail', function() use ($app) { sleep(5); $params = ZendJobQueue::getCurrentJobParams(); ZendJobQueue::setCurrentJobStatus(ZendJobQueue::OK); $response = new Response(); $response->headers->set('X-Info', 'mail send to '. $params['email']); return $response; });

MOVE SLOW REQUEST INTO JOB

Page 52: Zend Server: Not just a PHP stack
Page 53: Zend Server: Not just a PHP stack

/** * See Matthew Weier O'Phinney his blog serie about * Zend Server * * https://mwop.net/blog/2014-09-04-zend-server-deployment- * part-4.html */ if (! ZendJobQueue::getCurrentJobId()) { header('HTTP/1.1 403 Forbidden'); exit(1); }

SECURING JOB ACTIONS

Page 54: Zend Server: Not just a PHP stack

SCHEDULE A JOB

Page 55: Zend Server: Not just a PHP stack

$queue = new ZendJobQueue(); // send the as soon as possible $queue->createHttpJob('/sendemail', array('email'=>'[email protected]'), array( 'name'=>'Send email', 'priority' => ZendJobQueue::PRIORITY_URGENT ) );

AS SOON AS POSSIBLE

Page 56: Zend Server: Not just a PHP stack

$queue = new ZendJobQueue(); // send the email tomorrow 2am $queue->createHttpJob('/sendemail', array('email'=>'[email protected]'), array( 'name'=>'Send email', 'schedule_time' => date('Y-m-d h:i:s', strtotime('tomorrow 2am')) ) );

AT A SPECIFIC TIME

Page 57: Zend Server: Not just a PHP stack

$queue = new ZendJobQueue(); // send the email every Monday at 2am $queue->createHttpJob('/sendemail', array('email'=>'[email protected]'), array( 'name'=>'Send email', 'schedule' => '0 2 * * 1' ) );

RECURRING

Page 58: Zend Server: Not just a PHP stack

MANY MORE THINGS

Page 59: Zend Server: Not just a PHP stack

JAVA BRIDGE

LIBRARIES

OPCODE CACHING

CLUSTERING

APPLICATIONS

PAGE CACHING

WEB API

VIRTUAL HOSTS

CONTINUOUS DELIVERY

DATA CACHING

Page 60: Zend Server: Not just a PHP stack

JOIND.IN/12081


Recommended