the state of your own hypertext preprocessor

45
The state of your own hypertext processor Alessandro Nadalin 27/03/2012

Upload: alessandro-nadalin

Post on 08-May-2015

2.528 views

Category:

Technology


0 download

DESCRIPTION

Recap of a PHP journey and tips for devs

TRANSCRIPT

Page 1: The state of your own hypertext preprocessor

The state ofyour ownhypertext processor

Alessandro Nadalin

27/03/2012

Page 2: The state of your own hypertext preprocessor

What we had

Page 3: The state of your own hypertext preprocessor
Page 4: The state of your own hypertext preprocessor

PEAR / PECL

Page 5: The state of your own hypertext preprocessor
Page 6: The state of your own hypertext preprocessor
Page 7: The state of your own hypertext preprocessor
Page 8: The state of your own hypertext preprocessor

What we have

Page 9: The state of your own hypertext preprocessor
Page 10: The state of your own hypertext preprocessor
Page 11: The state of your own hypertext preprocessor
Page 12: The state of your own hypertext preprocessor

What you should look at

Page 13: The state of your own hypertext preprocessor

XHPROFhttps://github.com/facebook/xhprof

Page 14: The state of your own hypertext preprocessor

Traitshttp://php.net/manual/en/language.oop5.traits.php

Page 15: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 16: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 17: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 18: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 19: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 20: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 21: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 22: The state of your own hypertext preprocessor

trait XmlConversion { public function toXml() { $xml = new SimpleXMLElement('<object></object>'); foreach($this->getXmlAttributes() as $attribute) { $xml->addChild(new ...) } return $xml->asXml(); } abstract protected function getXmlAttributes();} class Person { use XmlConversion; protected function getXmlAttributes() { return ... }} class Log { use XmlConversion; protected function getXmlAttributes() { return ... }} $user = new Person();$user->toXml();$log = new Log();$log->toXml();

Page 23: The state of your own hypertext preprocessor

SPDYhttp://dev.chromium.org/spdy/spdy-whitepaper

Page 24: The state of your own hypertext preprocessor

PHP application serverhttp://www.photon-project.com/

Page 25: The state of your own hypertext preprocessor

HIncludehttp://mnot.github.com/hinclude/

Page 26: The state of your own hypertext preprocessor

<hx:include src="/footer.html"></hx:include>

Page 27: The state of your own hypertext preprocessor

<hx:include src="/footer.html"></hx:include>

Page 28: The state of your own hypertext preprocessor

<hx:include src="/footer.html"></hx:include>

Page 29: The state of your own hypertext preprocessor

Composerhttp://packagist.org/

Page 30: The state of your own hypertext preprocessor

{ "name": "robowhois/Robowhois", "type": "library", "description": "PHP SDK for Robowhois APIs.", "keywords": ["robowhois"], "license": "MIT", "authors": [ { "name": "Alessandro Nadalin", "email": "[email protected]", "homepage": "http://www.odino.org" }, { "name": "David Funaro", "email": "[email protected]", "homepage": "http://davidfunaro.com" } ], "autoload": { "psr-0": { "Robowhois": "src/" } }, "require": { "php": ">=5.3.2", "kriswallsmith/Buzz": "v0.5", "symfony/http-foundation": "v2.0.12" }}

Page 31: The state of your own hypertext preprocessor

{ "name": "robowhois/Robowhois", "type": "library", "description": "PHP SDK for Robowhois APIs.", "keywords": ["robowhois"], "license": "MIT", "authors": [ { "name": "Alessandro Nadalin", "email": "[email protected]", "homepage": "http://www.odino.org" }, { "name": "David Funaro", "email": "[email protected]", "homepage": "http://davidfunaro.com" } ], "autoload": { "psr-0": { "Robowhois": "src/" } }, "require": { "php": ">=5.3.2", "kriswallsmith/Buzz": "v0.5", "symfony/http-foundation": "v2.0.12" }}

Page 32: The state of your own hypertext preprocessor

{ "name": "robowhois/Robowhois", "type": "library", "description": "PHP SDK for Robowhois APIs.", "keywords": ["robowhois"], "license": "MIT", "authors": [ { "name": "Alessandro Nadalin", "email": "[email protected]", "homepage": "http://www.odino.org" }, { "name": "David Funaro", "email": "[email protected]", "homepage": "http://davidfunaro.com" } ], "autoload": { "psr-0": { "Robowhois": "src/" } }, "require": { "php": ">=5.3.2", "kriswallsmith/Buzz": "v0.5", "symfony/http-foundation": "v2.0.12" }}

Page 33: The state of your own hypertext preprocessor

{ "name": "robowhois/Robowhois", "type": "library", "description": "PHP SDK for Robowhois APIs.", "keywords": ["robowhois"], "license": "MIT", "authors": [ { "name": "Alessandro Nadalin", "email": "[email protected]", "homepage": "http://www.odino.org" }, { "name": "David Funaro", "email": "[email protected]", "homepage": "http://davidfunaro.com" } ], "autoload": { "psr-0": { "Robowhois": "src/" } }, "require": { "php": ">=5.3.2", "kriswallsmith/Buzz": "v0.5", "symfony/http-foundation": "v2.0.12" }}

Page 34: The state of your own hypertext preprocessor

wget http://getcomposer.org/composer.phar php composer.phar install

Page 35: The state of your own hypertext preprocessor

wget http://getcomposer.org/composer.phar php composer.phar install

Page 36: The state of your own hypertext preprocessor

wget http://getcomposer.org/composer.phar php composer.phar install

Page 37: The state of your own hypertext preprocessor

Interoperabilityhttps://github.com/php-fig/fig-standards

Page 38: The state of your own hypertext preprocessor

The new exec()https://github.com/symfony/Process

Page 39: The state of your own hypertext preprocessor

<?php require __DIR__ . '/vendor/.composer/autoload.php'; use Symfony\Component\Process\Process; $file = sys_get_temp_dir() . '/test.output.txt'; $handle = fopen($file, 'w+');$process = new Process('phpunit -c /home/foor/bar/phpunit.xml /home/foo/bar');$process->run(function ($type, $buffer) use($handle) { fwrite($handle, nl2br($buffer));}); fclose($handle);

Page 40: The state of your own hypertext preprocessor

<?php require __DIR__ . '/vendor/.composer/autoload.php'; use Symfony\Component\Process\Process; $file = sys_get_temp_dir() . '/test.output.txt'; $handle = fopen($file, 'w+');$process = new Process('phpunit -c /home/foor/bar/phpunit.xml /home/foo/bar');$process->run(function ($type, $buffer) use($handle) { fwrite($handle, nl2br($buffer));}); fclose($handle);

Page 41: The state of your own hypertext preprocessor

<?php require __DIR__ . '/vendor/.composer/autoload.php'; use Symfony\Component\Process\Process; $file = sys_get_temp_dir() . '/test.output.txt'; $handle = fopen($file, 'w+');$process = new Process('phpunit -c /home/foor/bar/phpunit.xml /home/foo/bar');$process->run(function ($type, $buffer) use($handle) { fwrite($handle, nl2br($buffer));}); fclose($handle);

Page 42: The state of your own hypertext preprocessor

<?php require __DIR__ . '/vendor/.composer/autoload.php'; use Symfony\Component\Process\Process; $file = sys_get_temp_dir() . '/test.output.txt'; $handle = fopen($file, 'w+');$process = new Process('phpunit -c /home/foor/bar/phpunit.xml /home/foo/bar');$process->run(function ($type, $buffer) use($handle) { fwrite($handle, nl2br($buffer));}); fclose($handle);

Page 43: The state of your own hypertext preprocessor

A "new" simple SAPIhttps://github.com/symfony/Console

Page 44: The state of your own hypertext preprocessor

<?php use Symfony\Component\Console\Command\Command;use Symfony\Component\Console\Output\OutputInterface;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Process\Process; class Install extends Command{ protected $installDir; protected $failingProcess; protected $dependenciesContainer; public function __construct(DependencyContainer $dependenciesContainer) { parent::__construct(); $this->dependenciesContainer = $dependenciesContainer; } protected function execute(InputInterface $input, OutputInterface $output) { if ($this->createInstallationDirectory($output) && $this->downloadComposer($output) && $this->generateJson($output) && $this->install($output)) { $output->writeln('<info>MISSION ACCOMPLISHED</info>'); } else { $output->writeln('<error>Nasty error happened :\'-(</error>'); if ($this->failingProcess instanceOf Process) { $output->writeln('<error>%s</error>', $this->failingProcess->getErrorOutput()); } } } protected function configure() { $this ->setName('install') ; }}

Page 45: The state of your own hypertext preprocessor

وداعا وداعا