<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Serverless on ZeroSharp</title><link>https://www.zerosharp.com/blog/categories/serverless/</link><description>Recent content in Serverless on ZeroSharp</description><generator>Hugo</generator><language>en-gb</language><copyright>Copyright © 2012–{year} Robert Anderson</copyright><lastBuildDate>Thu, 02 Mar 2017 11:37:00 +0100</lastBuildDate><atom:link href="https://www.zerosharp.com/blog/categories/serverless/index.xml" rel="self" type="application/rss+xml"/><item><title>Improvements to Serverless PHP support</title><link>https://www.zerosharp.com/improvements-to-serverless-php-support/</link><pubDate>Thu, 02 Mar 2017 11:37:00 +0100</pubDate><guid>https://www.zerosharp.com/improvements-to-serverless-php-support/</guid><description>&lt;p&gt;I was inspired by two events to jump back into serverless framework.&lt;/p&gt;
&lt;img class="img-left" src="https://www.zerosharp.com/images/blog/serverless-php-improvements-001.jpeg" alt="200 Serverless London Meetup"&gt;
&lt;p&gt;Firstly, I attended the second &lt;a href="https://www.meetup.com/Serverless-London/"&gt;London serverless meetup&lt;/a&gt; yesterday evening which was excellent and showed just how much enthusiasm there is for serverless architectures. Check out their new logo on the left. It was significant that each of the three speakers announced that they are actively hiring serverless developers.&lt;/p&gt;
&lt;p&gt;Secondly, &lt;a href="https://github.com/Stolz"&gt;Stolz&lt;/a&gt; has contributed improvements to my sample project for integrating PHP into the serverless framework. It&amp;rsquo;s the purpose of this blog post to cover the changes.&lt;/p&gt;</description></item><item><title>A concrete PHP Serverless example - export chess games in PDF</title><link>https://www.zerosharp.com/a-concrete-php-serverless-example/</link><pubDate>Tue, 29 Nov 2016 17:37:00 +0100</pubDate><guid>https://www.zerosharp.com/a-concrete-php-serverless-example/</guid><description>&lt;p&gt;In &lt;a href="https://www.zerosharp.com/the-serverless-framework-and-php/"&gt;the last post&lt;/a&gt; I built a PHP capable sample project for &lt;a href="https://serverless.com/"&gt;the Serverless Framework&lt;/a&gt;. In this post, I&amp;rsquo;ll show a concrete use of it.&lt;/p&gt;
&lt;p&gt;The service I&amp;rsquo;m building connects runs a PHP function for pretty-printing chess games from the &lt;a href="http://lichess.org/"&gt;lichess online chess server&lt;/a&gt;. &lt;a href="https://github.com/clarkerubber/lichessPDFExporter"&gt;James Clarke&lt;/a&gt; has written a PHP function to do this using &lt;a href="http://www.fpdf.org/"&gt;fpdf17&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The lichess exporter takes the game id of any game that has been played on the lichess server and produced a PDF output. Take for example, Game 8 of the current World Championship which is &lt;a href="https://en.lichess.org/COQChpzH"&gt;here&lt;/a&gt;. When I open the resulting file, I see this:&lt;/p&gt;</description></item><item><title>The Serverless Framework and PHP</title><link>https://www.zerosharp.com/the-serverless-framework-and-php/</link><pubDate>Mon, 21 Nov 2016 09:21:00 +0100</pubDate><guid>https://www.zerosharp.com/the-serverless-framework-and-php/</guid><description>&lt;p&gt;The goal of this post is to explain how to call a PHP function from within an AWS lambda using the &lt;a href="https://serverless.com/"&gt;Serverless Framework&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="prerequisites"&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;First check everything we need is installed.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ serverless --version
1.1.0
$ node --version
v7.1.0
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="install-the-sample-php-function"&gt;Install the sample PHP function&lt;/h2&gt;
&lt;p&gt;Install my sample &lt;em&gt;Hello&lt;/em&gt; function from my github repository.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sls install --url https://github.com/ZeroSharp/serverless-php
&lt;/code&gt;&lt;/pre&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Serverless: Downloading and installing &lt;span class="s2"&gt;&amp;#34;serverless-php&amp;#34;&lt;/span&gt;…
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Serverless: Successfully installed &lt;span class="s2"&gt;&amp;#34;serverless-php&amp;#34;&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h2 id="the-code"&gt;The code&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;$ cd serverless-php
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let&amp;rsquo;s have a look at the &lt;code&gt;serverless.yml&lt;/code&gt; file.&lt;/p&gt;</description></item><item><title>Serverless Framework Part 5: Pulling in a node package</title><link>https://www.zerosharp.com/serverless-framework-part-5-pulling-in-a-node-package/</link><pubDate>Tue, 09 Feb 2016 11:31:00 +0100</pubDate><guid>https://www.zerosharp.com/serverless-framework-part-5-pulling-in-a-node-package/</guid><description>&lt;p&gt;This is the final part of an ongoing series about the &lt;a href="https://github.com/serverless/serverless"&gt;Serverless framework&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the previous posts, the &lt;code&gt;PasswordGenerator&lt;/code&gt; always returned &amp;lsquo;Password&amp;rsquo;. Instead each date should corresponds to a new unique password. We&amp;rsquo;ll make use of the &lt;a href="https://www.npmjs.com/package/crypto-js"&gt;Crypto-js&lt;/a&gt; node package and we&amp;rsquo;ll see that the AWS lambda copes just fine.&lt;/p&gt;
&lt;h3 id="installing-a-node-package"&gt;Installing a node package&lt;/h3&gt;
&lt;p&gt;Pull in the crypto-js package into the serverless component.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cd nodejscomponent/
$ npm install crypto-js --save
crypto-js@3.1.6 node_modules/crypto-js
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we need the typescript definitions. Watch out there are two different TypeScript typings called &lt;em&gt;cryptojs&lt;/em&gt; and &lt;em&gt;crypto-js&lt;/em&gt;. The first one is more complete.&lt;/p&gt;</description></item><item><title>Serverless Framework - Part 4: Connecting the parts</title><link>https://www.zerosharp.com/serverless-framework-part-4-connecting-the-parts/</link><pubDate>Mon, 01 Feb 2016 09:44:00 +0100</pubDate><guid>https://www.zerosharp.com/serverless-framework-part-4-connecting-the-parts/</guid><description>&lt;p&gt;This is part of an ongoing series about the &lt;a href="https://github.com/serverless/serverless"&gt;Serverless framework&lt;/a&gt;: &lt;a href="https://www.zerosharp.com/serverless-framework-part-1-up-and-running/"&gt;Part 1&lt;/a&gt;, &lt;a href="https://www.zerosharp.com/serverless-framework-part-2-typescript-and-mocha/"&gt;part 2&lt;/a&gt;, &lt;a href="https://www.zerosharp.com/serverless-framework-part-3-the-guts/"&gt;part 3&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="new-version-031"&gt;New version 0.3.1&lt;/h2&gt;
&lt;p&gt;
&lt;span class="fluo"&gt;Edit: since the original version of this post, a new version 0.3.1 of Serverless was released. I have updated the tutorial below to reflect the newer version. Also, &lt;a href="https://github.com/DefinitelyTyped/tsd/issues/269"&gt;TSD has been deprecated&lt;/a&gt; in favour of &lt;a href="https://www.npmjs.com/package/typings"&gt;Typings&lt;/a&gt; so I&amp;rsquo;ve updated to use Typings instead.&lt;/span&gt;

All parts have been updated for the latest version of the framework 0.3.1.&lt;/p&gt;
&lt;h2 id="the-password-of-the-day-generator-class"&gt;The Password of the Day Generator class&lt;/h2&gt;
&lt;p&gt;First up we need a class to generate and check the password of the day. For the moment, let&amp;rsquo;s pretend the password of the day is always the string &lt;em&gt;&amp;ldquo;Password&amp;rdquo;&lt;/em&gt;. Put the following typescript class in &lt;em&gt;nodejscomponent/src&lt;/em&gt;.&lt;/p&gt;</description></item><item><title>Serverless Framework - Part 3: The guts of a serverless service</title><link>https://www.zerosharp.com/serverless-framework-part-3-the-guts/</link><pubDate>Fri, 29 Jan 2016 17:44:00 +0100</pubDate><guid>https://www.zerosharp.com/serverless-framework-part-3-the-guts/</guid><description>&lt;p&gt;This is part of an ongoing series about the &lt;a href="https://github.com/serverless/serverless"&gt;Serverless framework&lt;/a&gt;. For those following along, &lt;a href="https://www.zerosharp.com/serverless-framework-part-1-up-and-running/"&gt;part 1&lt;/a&gt; and &lt;a href="https://www.zerosharp.com/serverless-framework-part-2-typescript-and-mocha/"&gt;part 2&lt;/a&gt; have been updated for the current latest version of Serverless 0.3.1.&lt;/p&gt;
&lt;p&gt;In this post, we&amp;rsquo;ll discuss how a Serverless function actually works.&lt;/p&gt;
&lt;h2 id="the-guts-of-a-serverless-function"&gt;The guts of a serverless function&lt;/h2&gt;
&lt;p&gt;When we visited the deployed endpoint at the end of &lt;a href="https://www.zerosharp.com/serverless-framework-part-1-up-and-running/"&gt;part 1&lt;/a&gt;, it correctly returned some JSON content.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;message:&lt;/span&gt; &lt;span class="nt"&gt;&amp;#34;Your Serverless function ran successfully!&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Where does this message come from? Look at &lt;em&gt;index.js&lt;/em&gt; in the component&amp;rsquo;s &lt;em&gt;lib&lt;/em&gt; folder.&lt;/p&gt;</description></item><item><title>Serverless Framework - Part 2: TypeScript and Mocha</title><link>https://www.zerosharp.com/serverless-framework-part-2-typescript-and-mocha/</link><pubDate>Tue, 12 Jan 2016 08:08:00 +0100</pubDate><guid>https://www.zerosharp.com/serverless-framework-part-2-typescript-and-mocha/</guid><description>&lt;p&gt;Happy New Year everyone!&lt;/p&gt;
&lt;p&gt;This is the second part of a series about the &lt;a href="https://github.com/serverless/serverless"&gt;Serverless&lt;/a&gt; framework. Read &lt;a href="https://www.zerosharp.com/serverless-framework-part-1-up-and-running/"&gt;the first part&lt;/a&gt; to get up and running.&lt;/p&gt;
&lt;p&gt;First I&amp;rsquo;ll describe the webservice I&amp;rsquo;m building. Then we&amp;rsquo;ll configure our environment for Typescript and Mocha testing.&lt;/p&gt;
&lt;h2 id="poor-mans-dual-factor-authentication-via-a-password-of-the-day"&gt;Poor man&amp;rsquo;s dual factor authentication via a password of the day&lt;/h2&gt;



&lt;p&gt;I&amp;rsquo;m the technical lead for an enterprise application which is in use by about 100 large multinational corporates. As part of the installation process, we ask for a registration code which is based on the date. The customer has to call us to get the password of the day. This gives us an opportunity to engage with the customer and also gives us little more control. It&amp;rsquo;s a simple form of dual factor authorization where one of the factors requires a phone call.&lt;/p&gt;</description></item><item><title>Serverless Framework - Part 1: Up and running</title><link>https://www.zerosharp.com/serverless-framework-part-1-up-and-running/</link><pubDate>Tue, 22 Dec 2015 20:26:00 +0100</pubDate><guid>https://www.zerosharp.com/serverless-framework-part-1-up-and-running/</guid><description>&lt;h2 id="new-version-031"&gt;New version 0.3.1&lt;/h2&gt;

&lt;span class="fluo"&gt;Edit: since the original version of this post, a new version 0.3.1 of Serverless was released. I have updated the tutorial below to reflect the newer version.&lt;/span&gt;

&lt;p&gt;I was in the middle of a blog post about the JAWS framework and before I had finished it changed its name to &lt;a href="https://github.com/serverless/serverless"&gt;the Serverless framework&lt;/a&gt;. It is a very clever way to build apps without worrying about provisioning server or whether it will scale. This is because it uses Amazon Web Services and in particular the Amazon lambda compute service. It&amp;rsquo;s currently in beta.&lt;/p&gt;</description></item></channel></rss>