Wepay talk

This commit is contained in:
Rasmus Lerdorf
2014-05-29 09:28:56 -07:00
parent e700d6fb99
commit 04e21faa6c
2 changed files with 335 additions and 0 deletions

296
wepay14.html Normal file
View File

@@ -0,0 +1,296 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PHP</title>
<meta name="description" content="PHP">
<meta name="author" content="Rasmus Lerdorf">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="/reveal.js/css/reveal.min.css">
<link rel="stylesheet" href="/samdark.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="/styles/github.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = '/reveal.js/css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>PHP</h1>
<h3>Wepay</h3>
<h3>Palo Alto</h3>
<h3>May 29, 2014</h3>
<a href="http://talks.php.net/wepay14">http://talks.php.net/wepay14</a><br><br>
<p>Rasmus Lerdorf<br>
<small><a href="http://twitter.com/@rasmus">@rasmus</a></small>
</p>
</section>
<section>
<section id="performance">
<h2 margin-bottom="2em">PHP 5.5</h2><br>
<h3 class="p">Performance Improvements</h3>
<ul>
<li>Nested calls</li>
<li>Call stack pre-allocated by compiler</li>
<li>Bundled opcode cache</li>
</ul>
</section>
<section id="generators">
<h4 class="p">✔ Generators</h4>
<pre><code>function xrange($start, $end) {
for ($i = $start; $i &lt;= $end; $i ++) {
yield $i;
}
}
foreach (xrange(0, 5) as $i) {
echo $i, &quot;\n&quot;;
}</code></pre>
</section>
<section id="coroutines">
<h4 class="p">✔ Coroutines</h4>
<pre><code>function logger($fileName) {
$fileHandle = fopen($fileName, 'a');
while (true) {
fwrite($fileHandle, yield . &quot;\n&quot;);
}
}
$logger = logger(__DIR__ . '/log');
$logger-&gt;send('Foo');
$logger-&gt;send('Bar');</code></pre>
<p class="p">For an advanced explanation of coroutines, read this article by Nikita Popov</p>
<div align="" style="font-size: ; color: ; margin-left: ; margin-right: ; margin-top: ; margin-bottom: ;"><a href="http://nikic.github.io/2012/12/22/Cooperative-multitasking-using-coroutines-in-PHP.html" target="">Cooperative multitasking using coroutines</a></div><br />
</section>
<section id="finally">
<h4 class="p">✔ finally</h4>
<pre><code>$db = mysqli_connect();
try {
call_some_function($db);
} finally {
mysqli_close($db);
}</code></pre>
</section>
<section id="foreachlist">
<h4 class="p">✔ list() in foreach</h4>
<pre><code>$names = [ ['John','Smith'], ['Fred','Johnson'] ];
foreach($names as list($first,$last)) {
echo $first,$last;
}</code></pre>
</section>
<section id="constarray">
<h4 class="p">✔ Const array/string Dereferencing</h4>
<pre><code>echo array(1, 2, 3)[0]; //output 1
echo &quot;foobar&quot;[3]; //output b
echo [1,3,4][2]; //output 4</code></pre>
</section>
<section id="others">
<h4 class="p">✔ empty() support for functions/expressions</h4>
<h4 class="p">✔ curl upload functionality rewritten</h4>
<h4 class="p">✔ Simplified password hashing API</h4>
<pre><code>// Hash
$hash = password_hash(&quot;super secret&quot;,PASSWORD_BCRYPT);
// To validate $pwd against the stored hash
if (password_verify($pwd, $hash)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}</code></pre>
</section>
<section id="php55_done">
<div align="" style="font-size: ; color: ; margin-left: ; margin-right: ; margin-top: ; margin-bottom: ;"><a href="http://php.net/migration55" target="">php.net/migration55</a></div><br />
</section> </section>
<section>
<section id="php56">
<h2 margin-bottom="2em">PHP 5.6</h2><br>
<h4 class="p">✔ Variadic functions</h4>
<pre><code>class MySQL implements DB {
public function query($query, ...$params) {
$stmt = $this-&gt;pdo-&gt;prepare($query);
$stmt-&gt;execute($params);
return $stmt;
}
}
$q = 'SELECT * FROM users WHERE id = ?';
$user = $db-&gt;query($q, $userID)-&gt;fetch();</code></pre>
</section>
<section id="php56unpack">
<h4 class="p">✔ Argument Unpacking</h4>
<pre><code>// A better call_user_func_args
$args1 = [1, 2, 3];
$args2 = [4, 5, 6];
test(...$args1, ...$args2); // [1, 2, 3, 4, 5, 6]
test(1, 2, 3, ...$args2); // [1, 2, 3, 4, 5, 6]
test(...$args1, 4, 5, 6); // Fatal error: Cannot use positional argument after argument unpacking</code></pre>
</section>
<section id="php56constscalar">
<h4 class="p">✔ Constant scalar expressions</h4>
<pre><code>class Foo {
const FOO = 1 + 1;
const BAR = 1 &lt;&lt; 1;
const GREETING = &quot;HELLO&quot;;
const BAZ = self::GREETING.&quot; WORLD!&quot;
}</code></pre>
</section>
<section id="php56pow">
<h4 class="p">✔ Add right-associative power operator **</h4>
<pre><code>echo 2 ** 3 ** 2; // 512 (not 64)
echo -3 ** 2; // -9 (not 9)
echo 1 - 3 ** 2; // -8
echo ~3 ** 2; // -10 (not 16)</code></pre>
</section>
<section id="php56opoverload">
<h4 class="p">✔ Internal operator overloading for internal features like GMP</h4>
<pre><code>echo 2**512;
echo &quot;\n&quot;;
$n = gmp_init(2);
echo $n**512;</code></pre>
<pre><code>1.3407807929943E+154
13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096
</code></pre> </section>
<section id="php56use">
<h4 class="p">✔ use function and use const namespace imports</h4>
<pre><code>include 'template.inc';
include 'db.inc';
use function template\header, template\footer, db\query;
header('My Page');
query('select * from stuff');
footer();</code></pre>
</section>
<section id="php56_0">
<h4 class="p">✔ default_charset ini now applies to internal funcs</h4>
<h4 class="p">✔ SSL Peer verification by default</h4>
<h4 class="p">✔ openssl certificate fingerprints</h4>
<h4 class="p">✔ SAN x509 ext matching when verifying host names</h4>
<h4 class="p">✔ automatic DoS prevention of TLS renegotiation attacks</h4>
<h4 class="p">✔ and many more openssl-related options</h4>
</section>
<section id="php56_1">
<h4 class="p">✔ Asynchronous PostgreSQL database connections</h4>
<h4 class="p">✔ Non-blocking PostgreSQL queries</h4>
<h4 class="p">✔ New phpdbg SAPI</h4>
<h4 class="p">✔ Support for > 2GB file uploads</h4>
<h4 class="p">✔ The php://input stream is now re-usable</h4>
<h4 class="p">✔ Added hash_compare() for timing attack safe string comparison</h4>
<h4 class="p">✔ Added gost-crypto (CryptoPro S-box) hash algorithm</h4>
<h4 class="p">✔ FPM workers can now change their apparmor profile</h4>
<h4 class="p">✔ OCI8 Improvements</h4>
</section>
<section id="php56_done">
<div align="" style="font-size: ; color: ; margin-left: ; margin-right: ; margin-top: ; margin-bottom: ;"><a href="http://php.net/migration56" target="">php.net/migration56</a></div><br />
</section> </section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<h3 class="p">Are your deploys atomic?</h3>
<h3 class="p">Are you sure?</h3>
<h4 class="p">What happens to a request that is currently executing when you deploy?</h4>
</section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<img src="/presentations/slides/intro/dep1.png" width="642" height="300">
</section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<h4 class="p">✔ Don't copy files into current document root</h4>
<h4 class="p">✔ Let existing requests finish on old code</h4>
<h4 class="p">✔ New requests start on new code</h4>
<h4 class="p">✔ Avoid clearing your opcode cache</h4>
<h4 class="p">✔ Minimal impact on production traffic</h4>
</section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<img src="/presentations/slides/intro/dep2.png" width="680" height="428">
</section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<img src="/presentations/slides/intro/dep3.png" width="680" height="428">
</section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<h4 class="p">2 Document Root directories</h4>
<h4 class="p">Symlink /var/www/site toggles between them</h4>
<h4 class="p">realpath() symlink at the web server level</h4>
<h4 class="p">Set Document Root to symlink realpath</h4>
<h4 class="p">Never hardcode the document root in code</h4>
</section>
<section>
<h2 margin-bottom="2em">Deploying Web Apps</h2><br>
<h3 class="p">Apache</h3>
<h4 class="p">http://github.com/etsy/mod_realdoc</h4>
<h3 class="p">nginx</h3>
<h4 class="p">You can use $realpath_root</h4>
<p class="p">eg. fastcgi_param DOCUMENT_ROOT $realpath_root;</p>
<h3 class="p">PHP</h3>
<h4 class="p">http://github.com/etsy/incpath</h4>
</section>
<section>
<div align="" style="font-size: ; color: ; margin-left: ; margin-right: ; margin-top: ; margin-bottom: ;"><a href="http://codeascraft.com/2013/07/01/atomic-deploys-at-etsy/" target="">codeascraft.com/2013/07/01/atomic-deploys-at-etsy/</a></div><br />
</section>
</div>
</div>
<script src="/reveal.js/lib/js/head.min.js"></script>
<script src="/reveal.js/js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
backgroundTransition: 'none',
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/fade/none
transitionSpeed: 'fast',
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: '/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: '/highlight.pack.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: '/reveal.js/plugin/zoom-js/zoom.js', async: true, callback: function() { return !!document.body.classList; } },
{ src: '/reveal.js/plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>

39
wepay14.xml Normal file
View File

@@ -0,0 +1,39 @@
<presentation
template="simple"
navmode="html"
titlecolor="#000000"
navbarbackground="#bbbbbb"
navbartopiclinks="0"
logo1="images/php-med-trans.png"
titlesize="6em"
navbarheight="3.5em"
examplebackground="#ffffff"
outputbackground="#ffffff"
exampleclass="noshadow"
exampleoutputclass="noshadow"
>
<topic>PHP</topic>
<title>PHP</title>
<event>Wepay</event>
<location>Palo Alto</location>
<date>May 29, 2014</date>
<speaker>Rasmus Lerdorf</speaker>
<url>http://talks.php.net/wepay14</url>
<twitter>@rasmus</twitter>
<slide>slides/intro/titlepage.xml</slide>
<slide>slides/intro/php55.xml</slide>
<slide>slides/intro/php56.xml</slide>
<slide>slides/intro/atomic1.xml</slide>
<slide>slides/intro/atomic3a.xml</slide>
<slide>slides/intro/atomic2.xml</slide>
<slide>slides/intro/atomic3b.xml</slide>
<slide>slides/intro/atomic3c.xml</slide>
<slide>slides/intro/atomic3.xml</slide>
<slide>slides/intro/atomic4.xml</slide>
<slide>slides/intro/codeascraft.xml</slide>
</presentation>