<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sébastien Morel on Medium]]></title>
        <description><![CDATA[Stories by Sébastien Morel on Medium]]></description>
        <link>https://medium.com/@plopix?source=rss-f9c291e73d35------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*CiIzXQOt2d8CoLGu.jpg</url>
            <title>Stories by Sébastien Morel on Medium</title>
            <link>https://medium.com/@plopix?source=rss-f9c291e73d35------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:01:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@plopix/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A web application and an API with Salesforce Marketing Cloud using AMPScript, SSSJS and, React JS]]></title>
            <link>https://plopix.medium.com/a-web-application-and-an-api-with-salesforce-marketing-cloud-using-ampscript-sssjs-and-react-js-cd13cdedcdd0?source=rss-f9c291e73d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd13cdedcdd0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[marketing-cloud]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Sébastien Morel]]></dc:creator>
            <pubDate>Fri, 16 Jul 2021 21:58:20 GMT</pubDate>
            <atom:updated>2021-07-16T21:58:20.677Z</atom:updated>
            <content:encoded><![CDATA[<h4>A journey as a web developer with Data Extensions, Data Filters, Salesforce Objects, and more. From the web development process to a fully integrated Admin Interface in SFMC!</h4><h3>Introduction</h3><p>At <a href="https://almaviacx.com/">Almavia CX</a>’s Web &amp; Mobile business unit (former Novactive), we have been working on web applications for the past 20 years using various technologies, frameworks, and so on, with a bit more interest in Open Source technologies and stacks.</p><p>But since the acquisition and merge of Novactive with Almavia giving birth to Almavia CX, a new world has opened up: <a href="https://salesforce.com/"><strong>Salesforce</strong></a>. Now we are working with many new colleagues and clients who master different Salesforce “things”.</p><p>We are newbies with Salesforce in the Web &amp; Mobile business unit, we have some basic knowledge but nothing else, and that’s why we think this feedback, tips, and tricks might interest you whether you are in the same situation or already an experienced Salesforce person.</p><h3>Context</h3><p>For one of our existing customers, the job was to implement a custom Admin interface to build their Offers, to select Audiences, and create some Content to be sent via Email or Text.</p><p>Nothing crazy but to do that we had <strong>one</strong> strong <strong>constraint</strong> set by the customer itself.</p><blockquote>We needed <strong>to</strong> <strong>use Salesforce Marketing Cloud only</strong>, to <strong>build</strong>, <strong>run</strong> and <strong>host</strong> this application.</blockquote><p>We were introduced to AMP Script, and this good documentation: <a href="https://ampscript.guide/">https://ampscript.guide/</a> (Thanks Cyril Louis (best Salesforce MVP ever) for the tip.</p><p>Of course, Marketing Cloud is huge and therefore we split up the work with our SFMC experts from another Almavia CX unit. They did the Salesforce automation and we implemented the web application.</p><p>The brief description was simple:</p><ul><li>Using Landing Pages and AMPScript</li><li>Implement all required forms to search, create, edit, update and remove data</li><li>Retrieve and save data from/into Data Extensions</li></ul><p>A<em>ll the rest of the project (automation based on the Data Extensions) is hidden from the web application itself, and won’t be explained in this publication.</em></p><p>Before anything else, let’s define some concepts:</p><ul><li><strong>Data Extensions</strong>: That’s pretty much a database table</li><li><strong>Data Filters</strong>: We can see that as a Stored Procedure able to reach more than Data Extensions data.</li><li><strong>Landing Pages</strong>: a set of Zones and Blocks made to be WYSIWYG but in which you can also code in HTML/CSS/JS and AMPScript</li></ul><p>The application we had to build was quite standard:</p><ul><li>Authentication</li><li>Creation of the Offers, Audiences and, Contents</li><li>Synthesis and Validation pages</li><li>Tracking of the Offer progression over time</li></ul><p>So that was 6–7 fancy pages total, with a lot of fields, a lot of validations and pretty much each action needed to be saved into Data Extensions.</p><p>That’s how we started our first SF Marketing Cloud(SFMC) project.</p><h3>Step 1 — Data Modeling</h3><p>As with every project, one of the first important steps is to define the database.</p><p>With SFMC, to build your schema, there is an interface where you can create your table, fields, etc.</p><p>You can find it in Audience Builder &gt; Contact Builder &gt; Data Extensions.</p><p>For this application, we created around 10 data extensions for Users, Offers, Audiences, Content items, etc.</p><blockquote>Note that there is no constraint, nor foreign keys, nor indexes. Also the datamodel is not even driven by the source code. It’s what I could consider a bit old-school.</blockquote><h3>Step 2 — Authentication</h3><p>Most of the time that’s something we don’t think about in our projects, most of the applications we develop have an authentication system based on a session provided by the server.</p><p>Here, as the only things available to us are Data Extensions and Landing pages we had to rebuild the obvious in terms of authentication.</p><p>The mechanism is the following: On the login form submit, we check the login password against the data we have in the Data Extension. If that’s ok we create and save a unique token in the same Data Extension for that specific user (with an expiration) and also in a Cookie (with an expiration). After that, for each request, we check that the Cookie matched the token in the Data Extension. We lookup for the token in the Data Extension to retrieve the current user.</p><h3>Step 3 — Developments — First Try</h3><p>We started developing pages and for each page of the application, we created a Landing Page on SFMC.</p><p>That was terribly awful in terms of developer experience:</p><ul><li>No local development</li><li>AMP Script is really like PHP 3.x</li><li>You mix HTML and server-side code</li><li>No MVC, no framework, no structure</li><li>No real organization</li><li>You have to code in a small text area on a web page in SFMC</li><li>You cannot test locally</li><li>And to test your code you need to: Save the form, Publish and Wait</li></ul><p>And the top of the notch issue: you don’t have any debug/feedback when you have an error, just a dirty 500 error page.</p><blockquote>That was pretty much unbearable to build an application in such conditions.</blockquote><p>And with no framework, the code was so messy so quickly just to handle forms, validations, and navigation that we decided to improve the developer experience a little bit.</p><p>We are usually using <a href="https://symfony.com/">Symfony Framework</a> for our project. Here we did not need a full framework but a template system was a good idea to wrap the infamous AMPScript.</p><h3>Twig integration</h3><p>So we naturally used Twig as our template system to improve readability and reusability.</p><h4>Twig Functions</h4><p>That was the first simple nice addition, we could write our own function to generate AMPScript code.</p><p>So we develop some kind of framework on top of the AMPScript framework.</p><p>So instead of writing</p><pre>&lt;h1&gt;<strong>%%=v(@myVar)=%%</strong>&lt;/h1&gt;</pre><p>We would write</p><pre>&lt;h1&gt;<strong>{{ echo(‘myVar’) }}</strong>&lt;/h1&gt;</pre><p>This is a bit more readable but most of all this is a standard: Twig.</p><h4>Global configuration of our app</h4><p>Every application needs to have configurations:</p><ul><li>List for selects</li><li>Variables</li><li>Hostname</li><li>Routes</li><li>Etc.</li></ul><p>With Twig we just injected that configuration and that was available to us in the templates.</p><h4>Includes and inheritance</h4><p>Probably the BEST use case, the template system also brought us the capability to `<strong><em>include</em></strong>` and therefore to reuse code.</p><blockquote>That was a huge improvement.</blockquote><p>Let’s take the authentication check for instance. In native AMPScript for each landing page, we had to copy and paste the same piece of code. With Twig authenticated pages were just inheriting a specific layout.</p><pre><strong>{% extends &quot;layout/authenticated_page.amps.twig&quot; %}</strong></pre><pre>{% block page %}</pre><pre>… code of the page …</pre><pre>{% endblock %}</pre><p>The <em>layout/authenticated_page.amps.twig </em>code is:</p><pre>{% extends layout %}</pre><pre>{% block body %}<br>    {%  include &quot;layout/header.html.twig&quot; %}<br>    %%[<br>        set <a href="http://twitter.com/sessionId">@sessionId</a> = RequestParameter(&#39;sessionId&#39;);<br>        set <a href="http://twitter.com/rows">@rows</a> = LookupRows(&quot;{{ DE.Users }}&quot;,&quot;sessionId&quot;,<a href="http://twitter.com/sessionId">@sessionId</a>)<br>        if RowCount(<a href="http://twitter.com/rows">@rows</a>) != 1 then<br>    ]%%<br>    &lt;p&gt;<br>        SESSION INVALID PLEASE &lt;a href=&quot;{{ routes.login }}&quot;&gt;LOGIN&lt;/a&gt;<br>    &lt;/p&gt;<br>    &lt;meta http-equiv=&quot;refresh&quot; content=&quot;{{ redirect_timeout }}; url={{ routes.login }}&quot;&gt;<br>    %%[ else</pre><pre>        set <a href="http://twitter.com/firstname">@firstname</a> = Field(Row(<a href="http://twitter.com/rows">@rows</a>, 1), &#39;firstname&#39;)<br>        set <a href="http://twitter.com/lastname">@lastname</a> = Field(Row(<a href="http://twitter.com/rows">@rows</a>, 1), &#39;lastname&#39;)<br>        set <a href="http://twitter.com/email">@email</a> = Field(Row(<a href="http://twitter.com/rows">@rows</a>, 1), &#39;email&#39;)</pre><pre>]%%<br>    &lt;div class=&quot;container&quot;&gt;<br>        {% block page %}<br>            &lt;h1&gt;AUTHENTICATED PAGE&lt;/h1&gt;<br>            &lt;p&gt;<br>                Welcome {{ echo(&#39;<a href="http://twitter.com/firstname">@firstname</a>&#39;) }} {{ echo(&#39;<a href="http://twitter.com/lastname">@lastname</a>&#39;) }} {{ echo(&#39;<a href="http://twitter.com/email">@email</a>&#39;) }}<br>            &lt;/p&gt;<br>        {% endblock %}<br>    &lt;/div&gt;<br>    %%[ endif ]%%<br>{% endblock %}</pre><p>That was nice and efficient.</p><p>Then we needed to turn that code into final HTML.</p><h4>HTML, CSS and JS Integration</h4><p>AMPScript and Twig improved a lot the readability of the code, we wanted to feel the same for CSS and JS.</p><p>Same logic as before we wanted to base our development on standard tools and technologies. We decided to use Webpack and SASS.</p><p>The <a href="https://github.com/Novactive/SFMC-bootstrapper/blob/main/webpack.config.js">Webpack config</a> is really simple and standard. Using MiniCssExtractPlugin to extract the CSS.</p><p>And we finish the automation with a small script that injects the CSS and JS created by Webpack in the final HTML</p><pre>$page = $_SERVER[&#39;argv&#39;][1];</pre><pre>if (file_exists(&quot;build/{$page}.css&quot;)) {</pre><pre>    $config += [</pre><pre>        &#39;layout&#39; =&gt; &#39;layout/raw.html.twig&#39;,</pre><pre>        &#39;styles&#39; =&gt; trim(file_get_contents(&quot;build/{$page}.css&quot;)),</pre><pre>        &#39;javascripts&#39; =&gt; trim(file_get_contents(&quot;./build/{$page}.js&quot;))</pre><pre>    ];</pre><pre>}</pre><pre>echo $twig-&gt;render(&quot;{$page}.amps.twig&quot;, $config);</pre><p>So we could do:</p><pre>./generate offerpage &gt; page.amp</pre><h4>The build</h4><p>Like all good applications, we needed a build step.</p><p>So we created a Makefile</p><pre>build: ## Generate the AMP for all the page in build/</pre><pre>@$(YARN) build-prod</pre><pre>@$(PHP_BIN) bin/generate login &gt; build/login.amp</pre><pre>@$(PHP_BIN) bin/generate offer &gt; build/offer.amp</pre><pre>@$(PHP_BIN) bin/generate audience &gt; build/audience.amp</pre><pre>@$(PHP_BIN) bin/generate content &gt; build/content.amp</pre><pre>@$(PHP_BIN) bin/generate validation &gt; build/validation.amp</pre><pre>@$(PHP_BIN) bin/generate edit &gt; build/edit.amp</pre><pre>@$(PHP_BIN) bin/generate follow &gt; build/follow.amp</pre><h4>Deploy</h4><p>Ultimately using the make build we would generate our pages but we still had to follow those steps per page to deploy:</p><ul><li>Copy the code in the .amp file</li><li>Open the corresponding Landing Page in SFMC</li><li>Paste the code in that tiny textarea</li><li>Save</li><li>Publish &amp; wait a bit</li></ul><h4>Conclusion</h4><p>While this approach is perfectly valid for a small project, with 8 pages already, it was painful to update the code, test the overhaul, etc.</p><p>We were wasting too much time and when the functional rules started to change, without debugging tools or logs that was not possible to work in good conditions.</p><h3>Step 3 (Bis) — Developments — Final try</h3><p>At this step we knew AMPScript, most of the queries to retrieve/save into the Data Extensions were done.</p><p>The biggest problem was the interfaces, the interactions, the form validations, etc. the code was too messy and the impossibility to run code locally was a total waste of time.</p><p>And we also deep-dived into Google and Stackoverflow. Enough to discover and understand that Salesforce Server Side Javascript (as they named it in the doc) was probably a good idea to explore as a web developer, because well, javascript is part of our skillset.</p><p>So we completely switched our approach, we needed to find a way to:</p><ul><li>develop even more locally</li><li>debug</li><li>Improve developer experience</li><li>be more efficient and ready to changes</li></ul><p><strong>And naturally, we came up with a decoupled approach as we actually do all the time!</strong></p><p>We decided to reorganize our code to have:</p><ul><li>1 unique Landing Page for an API</li><li>1 unique Landing page for the Application (Front End)</li></ul><p>The API will be in full AMPScript and the Front End in React JS!</p><h3>API in AMPScript</h3><p>We wanted an API that would return JSON, first we tried to use a <em>Code Resource</em> instead of a Landing Page in SFMC but that did not work. Indeed the Code Resources are cached for a good 5 minutes making it impossible to test.</p><p>So we switched back to a Landing Page and started to use our existing AMPScript to do the first API endpoint to retrieve the offers.</p><p><strong>JSON Conversion Issue:</strong></p><p>That was an unexpected failure, there is no way to convert variables in JSON in AMPScript! And that makes sense, it has not been done for that.</p><p>Also, to retrieve a row you need to put all fields in a variable:</p><pre>%%[</pre><pre>var @rows, @row, @rowCount</pre><pre>set @rows = LookupRows(&quot;Offers&quot;,&quot;enabled&quot;, 1)</pre><pre>set @rowCount = rowcount(@rows)</pre><pre>if @rowCount &gt; 0 then</pre><pre>    for @i = 1 to @rowCount do</pre><pre>        var @emailAddress, @firstName</pre><pre>        set @row = row(@rows, @i)</pre><pre>        set @firstName = field(@row,&quot;firstName&quot;)</pre><pre>        set @emailAddress = field(@row,&quot;emailAddress&quot;)</pre><pre>next @i ]%%</pre><p>Then we should have built our JSON ourselves via CONCAT, managing the quotes, etc.</p><blockquote>It was an easy no go.</blockquote><p>This is when we looked more in detail at <strong>SSSJS</strong></p><h3>Salesforces Server Side JavaScript (SSSJS)</h3><p>First, we checked that everything we were doing with AMPScript could be done with SSSJS. The answer is YES. (and if that’s not you can still put AMScript in the middle).</p><p>So the fetching rows and convert them to JSON went from 15 to 20 lines of code to one:</p><pre>Platform.Response.Write(Stringify(Platform.Function.LookupRows(&quot;Offers&quot;, &quot;enabled&quot;, 1)))</pre><p>And we also found out that it was possible to have some error logs thanks to SSSJS</p><pre>&lt;script runat=&quot;server&quot;&gt;</pre><pre>Platform.Load(&quot;core&quot;, &quot;1.1&quot;);</pre><pre>try {</pre><pre>// ...your code</pre><pre>}catch (exception) {</pre><pre>// something with the exception like:  Stringify(exception)</pre><pre>}</pre><pre>&lt;/script&gt;</pre><blockquote>Here, that was a relief and the confirmation we were on the correct path.</blockquote><p>So we split the job, someone did the API and someone else did the front-end using ReactJS.</p><h3>React JS APP</h3><h4>In General</h4><p>Here, there is nothing specific to discuss, no specificity at all. Actually, it’s more interesting to look at all the benefits provided by a Single Page Application in the SFMC context.</p><p><strong>Benefits:</strong></p><ul><li>Complete autonomy to build the user interface</li><li>Local development fully functional</li><li>The whole world of plugins, components via NPM or Yarn.</li></ul><p><strong>Disadvantages:</strong></p><ul><li>Developments have to be done locally, they are unreadable in SFMC as the code will be compiled.</li></ul><h4>React Router</h4><p>Using “react-router-dom” we could build as many pages as we wanted using only one Landing Page (Single Page App). No more full reload of the Landing Page. The user experience was also really improved as you know React just reloads what’s necessary.</p><h4>Local storage</h4><p>A huge improvement as well here in terms of Developer eXperience but also User eXperience. As mentioned before there is no session mechanism server side. Therefore we have no state that could stay in the application unless that state is client-side.</p><p>And using the wonderful “@rehooks/local-storage” we could save the state of the application in the Local storage allowing us to:</p><ul><li>Create some sort of simple state to save context and improve the user experience when they come back, and browse the application.</li></ul><h4>Fake endpoint</h4><p>The point is self-explanatory! As the approach is decoupled, the front-end developer was able to have fake endpoints to work waiting for the API to be finished. A small addition but a huge facilitator.</p><h3>Conclusion</h3><p>To sum up, at the end of the journey, here is the final stack/approach.</p><p>A Landing page that will receive the Front End Application:</p><ul><li>Built with React JS</li><li>Fully standard, no Salesforce knowledge needed here</li><li>Our build step extracts compiled and packed JS, CSS, and HTML that we copy and paste in the SFMC textareas.</li></ul><p>A Landing Page that will receive the API SSSJS</p><ul><li>Using SSSJS and/or AMPscript</li><li>Still using Twig as a template system to inject configuration and give more readability.</li><li>Mockable: you can mock/redefine Platform.* functions to also develop locally and in JS</li></ul><h3>Feedback and going further</h3><p>To me, that is the way to go. It’s efficient, decoupled, and workable.</p><p>That being said, that’s not optimal for many reasons:</p><ul><li><strong>We are still required to copy/paste manually and publish code</strong>: We did not find a way to push the code there directly.</li><li><strong>There are no staging environments</strong>: You need to do it yourself, using a different set of Landing Pages, it seems odd.</li><li><strong>Data Extensions are not a database</strong>: Join must be done manually and that’s cumbersome</li><li><strong>Cookie HTTP Only flag is off “in the sandbox”:</strong> And it is on in the real organization. So be aware of this from the beginning.</li><li><strong>Datetimes are always converted to GMT-6 in SFMC:</strong> again something you need to know from the start, it will help you when working with many timezones.</li></ul><p>I personally think that is a lot of workaround for such a simple project that could have been done with standard tools.</p><p>I wonder if we could have reached the Salesforce API to fetch data remotely and handle the application outside of the Salesforce Marketing Cloud while still using its concepts.</p><p><strong>But then comes the security arguments, in the approach used and required by our client, everything stays on Salesforce, nothing goes outside nothing transit.</strong></p><p>Also, there is no hosting outside of SFMC which might be worth the extra time for a small application.</p><p>During this journey, I always wondered: “how are others doing?” There has to be another way. We did not find it and would love to discuss it! Don’t hesitate to comment! This publication is more about sharing an experience rather than showing a unique truth!</p><p>Also if we need to do another application like this, we would definitely use the same final approach, we would be really efficient actually.</p><p>And because of that, and because we also love Open Source, we released a BootStrapper to accelerate the installation if you ever want to try that approach!</p><p>Here is the Bootstrapper: <a href="https://github.com/Novactive/SFMC-bootstrapper"><strong>https://github.com/Novactive/SFMC-bootstrapper</strong></a></p><h3>How to use Almavia CX SalesForce Marketing Cloud Bootstrapper</h3><p>We made it really simple for you to bootstrap a project following the approach of this publication.</p><p>First, you need the minimum tooling of course:</p><ul><li>PHP</li><li>Composer</li><li>Yarn</li><li>Make</li></ul><p>And then that’s really simple</p><pre>composer create-project almaviacx/sfmc-bootstrapper mysfmcapp --no-interaction</pre><p>The project will install itself in the `<strong>mysfmcapp`</strong> directory. You can run the webserver with make serve and the interface can be reached at a localhost URL.</p><p>Then whenever, you are ready to deploy, you need:</p><ul><li>make build</li><li>copy/paste the content of <em>build/app.amp</em> file for the app Landing Page</li><li>copy/paste the content of <em>build/api.amp</em> file for the API Landing Page</li></ul><p><strong>Enjoy!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd13cdedcdd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ibexa, Platform.sh and Fastly Image Optimisations]]></title>
            <link>https://plopix.medium.com/ibexa-platform-sh-and-fastly-image-optimisations-a4ef7680c65?source=rss-f9c291e73d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4ef7680c65</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[fastly]]></category>
            <category><![CDATA[ibexa]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[platformsh]]></category>
            <dc:creator><![CDATA[Sébastien Morel]]></dc:creator>
            <pubDate>Tue, 01 Dec 2020 07:30:00 GMT</pubDate>
            <atom:updated>2020-12-01T08:56:18.612Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ibexa, Platform.sh and Fastly Image Optimizations</h3><h3>Context</h3><p>I love <a href="https://www.ibexa.co/">Ibexa DXP</a> (former eZ Platform) because it is based on top of <a href="https://symfony.com/">Symfony</a> 5 and it brings everything you need to build a great Digital eXperience Platform and even more for our clients. You’ve got the full Symfony power, a GraphQL API, a cool Admin UI, it’s by definition headless, multilingual, multi-channel, no design in the database, good separation of concerns, great PHP API, you get a Content Repository (a tree/graph and not just a list of Content Items), and, HTTP Cache is well managed. And to me, HTTP Cache is key to scalability, reliability and, performance. And I do like performances.</p><p>That’s also why I like <a href="https://www.fastly.com/">Fastly</a>! How could we not, Fastly is a CDN based on <a href="https://varnish-cache.org/">Varnish</a>. So if you know HTTP Cache and Varnish you must love Fastly. The best thing about Fastly is the capability of clearing caches based on keys.</p><blockquote>There are only two hard things in Computer Science: <strong>cache invalidation</strong> and <strong>naming things</strong> — Phil Karlton</blockquote><p>When I set up our projects I have long TTLs and a good cache clearing mechanism thanks to Edge Side Includes(ESI), Symfony and, Ibexa DXP. We usually achieve about <strong>98% hit ratio</strong> on projects.</p><p>But components between the software and the Content Delivery Network (CDN) are as important as the rest of the architecture. My choice is the Platform a as Service (PaaS): <a href="https://platform.sh/">Platform.sh</a>.</p><p>They provide that glue between the software and the edges (Fastly). With Platform.sh you select the services you want and you use it, you don’t waste time to set them up, optimize them, and patch them, they do that for you (and more: backups, monitoring etc.).</p><p>My standard stack is:</p><ul><li>PHP 7.4+ (8 is available already) for performances</li><li>MySQL 8 for performances and JSON functions. (starting to move to Postgresql on few projects)</li><li>Rabbit MQ for asynchronous</li><li>Redis for application cache</li><li>And Varnish (and/or Fastly) for HTTP cache</li></ul><p>Platform.sh is git-driven, for each branch you have on your repository, you get a new environment that is cloned and available right away to test your features. Project managers and clients really appreciate it.</p><blockquote>We don’t have Fastly for each of them so we have Varnish (which is the same) on which we fallback.</blockquote><h3>Fastly Image Optimizer</h3><p>Fastly as a CDN has cool features like Web Application Firewall but the one of interest here, is the Image Optimizer.</p><p>Fastly is already between the world and your architecture (called the origin), it acts as a shield and it optimizes the Time To First Byte (TTFB) because pages your visitors download are closer to them.</p><p>So as they are in the middle already, why not acting like an Image Optimizer so your application does not have to handle this?</p><p>Well, that is exactly what is <a href="https://www.fastly.com/products/web-and-mobile-performance/image-optimization">Fastly Image Optimizer</a>, it optimizes your images on the fly!</p><h3>Ibexa DXP default image handling</h3><h4><em>Let’s step back a bit and review the default Ibexa mechanism regarding images.</em></h4><p>By default, Ibexa DXP provides a concept of “variation” (previously known as “aliases”). This is a feature that many CMS still lack. It enables developers to make sure images are rendered in an optimized way in the various places they need to appear, for example: on a homepage at a certain size and on a detailed article page at a different size. This already helps prevents editors from loading super-heavy images directly into pages.</p><p>By default, these image variations are generated with <a href="https://github.com/liip/LiipImagineBundle">LiipImagineBundle</a>, using the underlying <a href="https://github.com/avalanche123/Imagine">Imagine</a> library. It supports GD, Imagick, or Gmagick PHP extensions, and allows you to define a flexible filter to convert your original images into multiple “variations” as well as post processor like <a href="https://pngquant.org/">PNGQuant</a>, <a href="https://www.mankier.com/1/jpegoptim">JpegOptim</a> etc.</p><p>Ibexa DXP also abstracts the file system using <a href="https://flysystem.thephpleague.com/">FlySystem</a>. By default, variations are stored on the local file system, but you can configure it to store those images in an AWS S3 bucket if you wish. Obviously, they are generated only once and cleared on demand (e.g. content removal or publication).</p><p>Here is an example of a variation definition:</p><pre>simple:<br>    reference: ~<br>    filters:<br>        — { name: auto_rotate }<br>        — { name: geometry/scaledownonly, params: [128,128] }<br>        — { name: strip }</pre><p>A more complex one:</p><pre>complex:<br>    reference: ~<br>        filters:<br>            — { name: auto_rotate }<br>            — { name: geometry/scaledownonly, params: [326,280] }<br>            — { name: geometry/crop, params: [326, 280, 0, 0] }<br>            — { name: background, params: { size: [230, 144], color: ‘#FFFFFF’ } }<br>            — { name: strip }</pre><p>But with no CDN your architecture still needs to manage the conversion, storage, delivery, and caching. You are also limited to the PHP extension capabilities and the delivery capabilities of your servers/tools/CPUs and memory.</p><h3>Introducing Nova eZ Fastly Image Optimizer</h3><p>That is so simple to use that I could not resist releasing an open-source bundle to leverage it for Ibexa DXP, the same way we did for <a href="https://cloudinary.com/blog/dynamic_image_manipulation_and_optimization_is_ez_er_with_the_novactive_ez_platform_cloudinary_connector1">Cloudinary</a>.</p><blockquote>Cloudinary is definitely similar and even more powerful but it requires more to setup as well. It could also act as a full Digital Asset Management, this is also an amazing service that you should check out.</blockquote><p>The bundle will give you the ability to create variations based on Fastly Image Optimization features. In other words, <a href="https://docs.fastly.com/en/guides/image-optimization-api">every manipulation feature available in Fastly</a> will be yours as soon as you finish the installation.</p><p>There is no code to change, just the variations to define, and if you don’t define them, the plugin will fallback to the standard handling.</p><p>Example of a Fastly variation:</p><pre>fastlyio_variations:<br>    bright:<br>        filters:<br>            width: 200<br>            height: 100<br>            brightness: -50<br>            blur: 50<br>            fit: bounds</pre><blockquote>The “filters” key enables you to use all possibilities and combinations provided by Fastly.</blockquote><h3>How Does it Work?</h3><p>The first time the image is requested, Fastly automatically fetches the original image from your architecture(origin) and performs the requested manipulations, caches it, and serves it.</p><p>Behind the scene, the bundle adds the correct parameter to indicate to Fastly what are the manipulations to do.</p><p>So an image with this URL: https://yoursite.com/var/novactive/storage/images/_aliases/myvariation/2/6/2/5/5262-1-fre-FR/header.png will turn into</p><p>https://yoursite.com/var/novactive/storage/images/2/6/2/5/5262–1-fre-FR/header.png?width=800&amp;height=350&amp;fit=bounds</p><blockquote>Notice that when using Fastly we do the manipulations on the original images the quality is even better!</blockquote><p>That’s it!</p><h3>Conclusion</h3><p>There are a lot of reasons that recently your website’s traffic might have increased…(I hope you are all safe wherever you are). Fastly helps to reduce bottleneck on your architecture. Bandwidth, cost, performances, and ultimately user experience are key for your business.</p><h4>Milliseconds matter!</h4><p>All the services and software mentioned in this article help you to optimize your value chain and therefore help you to increase your business efficiency.</p><p>If you’ve never tried Platform.sh I would really recommend it. No more necessary DevOps tasks, focus on what matters for your business.</p><p>The same goes for Ibexa DXP, don’t hesitate to reach out. Don’t select a trendy CMS that needs a complete revamp every 2 years, select a product supported by an editor with a strong ecosystem of partners!</p><p>For both, I can do a demo for/with you ;-)</p><p>Enjoy!</p><p>The package is open-source and available on our Github here: <a href="https://github.com/Novactive/NovaeZFastlyImageOptimizerBundle">https://github.com/Novactive/NovaeZFastlyImageOptimizerBundle</a></p><p>You can find all the bundles that we proudly maintain here: <a href="https://github.com/Novactive/Nova-eZPlatform-Bundles">https://github.com/Novactive/Nova-eZPlatform-Bundles</a></p><p><a href="https://www.novactive.com/">Novactive</a> by <a href="https://nextedia.com/">Nextedia</a> supports the Symfony, Ibexa, and Platform.sh communities!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4ef7680c65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eZ Accelerator is back!]]></title>
            <link>https://plopix.medium.com/ez-accelerator-is-back-e3fcf43e31c9?source=rss-f9c291e73d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3fcf43e31c9</guid>
            <category><![CDATA[ez-platform]]></category>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[dxp]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Sébastien Morel]]></dc:creator>
            <pubDate>Mon, 20 Jul 2020 23:10:09 GMT</pubDate>
            <atom:updated>2020-07-20T23:10:09.018Z</atom:updated>
            <content:encoded><![CDATA[<h4>And it brings asynchronicity in eZ Platform via Symfony Messenger.</h4><p>I was waiting for it for a while and they did it a few months ago:</p><blockquote><strong>eZ Platform 3.x is now fully based on Symfony 5</strong>.</blockquote><p>While it’s great in terms of dependencies and deprecations mechanism for the future, it’s awesome in terms of features and components we can now use. We move from Symfony 3.4 to 5.x that’s something.</p><p>Almost 10 years ago we released <a href="https://www.slideshare.net/morelseb/e-z-accelerator13en">eZ Accelerator for eZ Publish</a>. Back then the benefits were enormous because we were adding HTTP cache using Varnish on top of eZ.</p><p>Despite the fact <a href="https://ezplatform.com/">eZ Platform</a> does not have any performance issues, the more the better and being able to do actions asynchronously is always an improvement.</p><p>Welcome <a href="https://github.com/Novactive/NovaeZAccelerator">eZ Accelerator</a> for <a href="https://ibexa.co/">eZ Plaform the DXP by Ibexa</a>.</p><p>This new bundle leverages <a href="https://symfony.com/doc/current/components/messenger.html">Symfony Messenger</a> and adds asynchronicity to eZ Platform allowing many things with no overhead and quite the opposite accelerating native actions.</p><p>For now, it allows you to:</p><ul><li>catch and dispatch<strong> asynchronous</strong>ly<strong> </strong>any<strong> Events</strong>.<br>A small bullet point but a wide range of subjects can be addressed here from the simple <strong>content management features</strong> to the<strong> e-commerce features</strong> through <strong>personalization features</strong>. All the DXP will benefit from this. <em>(Careful though not all events can be handle asynchronously)</em></li><li>handle <strong>HTTP Cache Purge asynchronous</strong>ly</li><li>handle <strong>Search Indexation asynchronous</strong>ly</li><li><em>what else? you tell us (comment here, or the Github Issue is open) and/or you’re welcome as a contributor if you feel like it!</em></li></ul><p><strong>Native Bonus</strong>: You can inject Middlewares into the game and any other cool stuff Symfony Messenger is providing.</p><p>The bundle is just a first step, I would love it to be enriched by the great community we have.</p><h3>Implementation</h3><p>That was kind of straight forward:</p><ul><li>decorations of services to call the bus instead of doing the actions right away</li><li>a compiler pass to listen to user-configured event to dispatch through the bus.</li><li>a semantic configuration to make it simpler for users</li><li>some tricks to manage the “SiteAccess Awareness”</li></ul><h3>SiteAccess Aware</h3><p><a href="https://doc.ezplatform.com/en/latest/guide/siteaccess/">SiteAccess</a> management is always tricky, the bundle includes a MiddleWare that will tag messages so you can have access to the original SiteAccess in the Handler.</p><p>But that is not enough, the consumers are long-running scripts and they could handle different Messages coming from different SiteAccess and therefore with a different configuration. Thankfully Symfony Messenger comes with 2 options that will help you in those situations:</p><ul><li><strong>receiver</strong>: so you can specify what transport to consume</li><li><strong>bus</strong>: so you can specify the bus o dispatch received messages</li></ul><p>Using those configurations + the native <strong>siteaccess</strong> option that comes with eZ Platform you should be fine.</p><h3>Conclusion</h3><p>This is only the first version! As mentioned it could become something more, if we all contribute ;-)</p><p>eZ Accelerator for eZ Publish ended up being integrated into the eZ Publish kernel, my guess is Symfony Messenger in eZ Platform makes so much sense.</p><p>Anyway, we are proud and excited to release this first version of <a href="https://github.com/Novactive/NovaeZAccelerator">eZ Accelerator</a>.</p><p>The documentation is ready, please enjoy the beta1 and don’t hesitate to give us your feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3fcf43e31c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony Local Server, Docker, and Varnish]]></title>
            <link>https://plopix.medium.com/symfony-local-server-docker-and-varnish-189e5a892439?source=rss-f9c291e73d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/189e5a892439</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[ez-platform]]></category>
            <dc:creator><![CDATA[Sébastien Morel]]></dc:creator>
            <pubDate>Fri, 22 Mar 2019 02:42:39 GMT</pubDate>
            <atom:updated>2019-03-22T03:28:04.113Z</atom:updated>
            <content:encoded><![CDATA[<h4>A first approach of a complex setup locally with full performances.</h4><h3>Context</h3><p>Researching resources before writing this post, I found this nice article from <a href="https://jolicode.com/blog/mon-serveur-local-avec-le-binaire-symfony">https://jolicode.com/blog/mon-serveur-local-avec-le-binaire-symfony</a> which is a really good introduction. This is in French but you have also the original slides by @fabpot <a href="https://symfony.com/blog/local-web-server-reloaded-for-symfony-apps">https://symfony.com/blog/local-web-server-reloaded-for-symfony-apps</a>.</p><p>Being the author of <a href="https://medium.com/@Plopix/ez-platform-cloud-and-ez-launchpad-dont-host-don-t-deploy-don-t-install-just-code-6140d75a439d">eZ Launchpad for eZ Platform</a>, I was eager to test that Symfony Local Web Server on a pure Symfony 4 project. And I wanted for this project to have awesome performances for my team on Mac OSX and on Linux. Getting the best performances on Mac OSX with Docker means using the local PHP and not having the PHP running inside a Docker container.</p><blockquote>There is a counterpart of the approach, you need to install more stuff locally. More on that part in my feedback at the end.</blockquote><h3>Docker Stack</h3><p>The services we usually have<br>- MariaDB<br>- Rabbit MQ<br>- Mailcatcher<br>- Redis<br>- Varnish</p><p>Here is our Dockerfile</p><pre><strong>version</strong>: &#39;3&#39;<br><strong>services</strong>:<br>    <strong>db</strong>:<br>        <strong>image</strong>: &#39;mariadb:10.2&#39;<br>        <strong>environment</strong>:<br>            - MYSQL_ROOT_PASSWORD=xxxx<br>        <strong>ports</strong>:<br>            - &#39;${PROJECTPORTPREFIX}306:3306&#39;<br><br>    <strong>rabbitmq</strong>:<br>        <strong>image</strong>: &#39;rabbitmq:3.7-management&#39;<br>        <strong>environment</strong>:<br>            - RABBITMQ_DEFAULT_USER=xxxx<br>            - RABBITMQ_DEFAULT_PASS=xxxx<br>        <strong>ports</strong>:<br>            - &#39;${PROJECTPORTPREFIX}672:5672&#39;<br>            - &#39;${PROJECTPORTPREFIX}673:15672&#39;<br><br>    <strong>mailcatcher</strong>:<br>        <strong>image</strong>: schickling/mailcatcher<br>        <strong>ports</strong>:<br>            - &#39;${PROJECTPORTPREFIX}180:1080&#39;<br><br>    <strong>redis</strong>:<br>        <strong>image</strong>: &#39;redis:5&#39;<br>        <strong>ports</strong>:<br>            - &#39;${PROJECTPORTPREFIX}379:6379&#39;<br><br>    <strong>varnish</strong>:<br>        <strong>image</strong>: plopix/docker-varnish6<br><strong>        network_mode</strong>: host<br>        <strong>volumes</strong>:<br>            - &#39;./varnish/backend.vcl:/etc/varnish/backend.vcl:ro&#39;<br>            - &#39;./varnish/varnish.vcl:/etc/varnish/default.vcl:ro&#39;<br>        <strong>ports</strong>:<br>            - &#39;${PROJECTPORTPREFIX}082:80&#39;</pre><p>As you can see, we don’t need Nginx or a container for PHP any more! Thank you Symfony Local Server!</p><blockquote>The concept of <em>PROJECTPORTPREFIX</em> allows you to define a TCP Port per project so you don’t have to stop containers when working on multiple projects.</blockquote><p>My Symfony env.local looks like that:</p><pre>DATABASE_URL=mysql://root:xxxxx@127.0.0.1:13306/xxxxx<br>REDIS_CACHE_URL=redis://127.0.0.1:13379<br>REDIS_SESSION_URL=redis://127.0.0.1:13379<br>MAILER_URL=smtp://127.0.0.1:13180<br>MESSENGER_TRANSPORT_DSN=amqp://xxxxx:xxxxx@127.0.0.1:13672/%2f/messages?queue[attributes][delivery_mode]=2</pre><p>Boum! that’s it symfony:local:start --port 13080 -d</p><blockquote>You will see that the Makefile automates everything</blockquote><p>Still, we have 2 issues with Varnish here:<br><strong>1/</strong> It does not know how to talk to an HTTPS backend<br><strong>2/</strong> the backend itself will be different on Mac OSX and on Linux</p><h3>1/ Varnish and Symfony “prod” mode</h3><p>Indeed if you want to test your code with Varnish it makes sense to be in “prod” mode on your Symfony application. So you have to prefix the Symfony Local Server command with APP_ENV=prod</p><p>And regarding the HTTPS, you can tackle that issue with the option --no-tls to start our Symfony Local Server in HTTP.</p><blockquote>You will see in the Makefile below.</blockquote><h3>2/ OS-aware backend definition for Varnish</h3><p>On Linux your container can reach the host using localhost when you are in network mode host and on Mac OSX it can be reached to host.docker.internal</p><p>You should then have 2 files:</p><p>The first one for Linux</p><pre>backend symfony {<br>    .host = &quot;localhost&quot;;<br>    .port = &quot;13081&quot;;<br>}</pre><p>And the one for Mac OS</p><pre>backend symfony {<br>    .host = &quot;host.docker.internal&quot;;<br>    .port = &quot;13081&quot;;<br>}</pre><p>And the global VCL:</p><pre>vcl 4.0;<br>import std;<br>import xkey;<br><br>include &quot;backend.vcl&quot;;</pre><pre>... following by all your Varnish logic...</pre><p>So we need to change that backend depending on the host OS. Thanks to Varnish include function combined with an override on the mount points, you can do that.</p><pre><strong>version</strong>: &#39;3&#39;<br><strong>services</strong>:<br>    <strong>varnish</strong>:<br>        <strong>volumes</strong>:<br>            - &#39;./varnish/backend_osx.vcl:/etc/varnish/backend.vcl:ro&#39;</pre><p>This is the docker-composer-osx.yaml file in which we are mounting a specific VCL file when we are on Mac OS X.</p><blockquote>You will see that the Makefile will adapt the docker-compose command line depending on the kernel.</blockquote><h3>Makefile</h3><p>When we are putting everything all together:</p><pre><em># Variables<br></em>PORT_PREFIX := 13<br>PHP := php<br>SYMFONY := symfony<br>DOCKER_COMPOSE := PROJECTPORTPREFIX=$(PORT_PREFIX) docker-compose -p myprojectname -f provisioning/dev/docker-compose.yaml<br>APP_DIR := $(shell pwd)/application<br>UNAME_S := $(shell uname -s)<br><strong>ifeq</strong> ($(UNAME_S),Darwin)<br>DOCKER_COMPOSE :=  $(DOCKER_COMPOSE) -f provisioning/dev/docker-compose-osx.yaml<br><strong>endif</strong><br><br>.PHONY: serve<br>serve: stop <em>## Start the web server in DEV mode, HTTPS, without Varnish<br></em>   @$(DOCKER_COMPOSE) up -d<br>   @cd $(APP_DIR) &amp;&amp; $(PHP) bin/console cache:clear<br>   @cd $(APP_DIR) &amp;&amp; $(SYMFONY) local:server:start --port=$(PORT_PREFIX)080 -d<br><br>.PHONY: varnishserve<br>varnishserve: stop <em>## Start the web server in PROD mode, no HTTPS, through Varnish</em><br>   @$(DOCKER_COMPOSE) up -d<br>   @cd $(APP_DIR) &amp;&amp; APP_ENV=prod $(PHP) bin/console cache:clear<br>   @cd $(APP_DIR) &amp;&amp; APP_ENV=prod $(SYMFONY) local:server:start --no-tls --port=$(PORT_PREFIX)081 -d<br><br>.PHONY: stop<br>stop: <em>## Stop the web server if it is running<br>   </em>@cd $(APP_DIR) &amp;&amp; $(SYMFONY) local:server:stop<br>   @$(DOCKER_COMPOSE) stop</pre><h3>Conclusion</h3><p>Now you can work in ‘dev’ mode through HTTPs using make serve. This is really helpful to work with HTTP/2 and HTTP/2 Server Push for instance (<em>did not try yet the HTTP/2 Server Push</em>).</p><p>And when you need Varnish to test in ‘prod’ mode with a real HTTP cache server (Varnish): use make varnishserve.</p><h3>To go Further</h3><p>Actually, the best way would be to have HTTPS in front of Varnish. But as Symfony Local Server provides HTTPS for us that approach is the most pragmatic approach I have found.</p><blockquote>You can achieve HTTPS in front of Varnish using <em>haproxy</em> for instance. But usually we have a PREPRODuction setup correctly to handle HTTPS and for local dev what described is enough! But don’t hesitate to comment with your solution!</blockquote><h3>My feedback</h3><p>At Novactive we are working a lot on eZ Platform and therefore with eZ Launchpad which brings everything out of the box. I am usually not that comfortable to ask developers to install specific versions of PHP, yarn, node, convert, or anything locally on their computer. To me, that’s the power of Docker and that what’s should be used, that’s the perfect answer to those onboarding problems.</p><p>To illustrate this, the requirements for a fresh installation goes from Docker only to Docker, PHP, PHP-FPM, composer, yarn etc. Plus the PHP extensions, and for instance to install amq extension (with pecl) you need to install RabbitMQ client locally brew install rabbitmq-c.</p><p>So this approach kind of break the golden rule, but as for any rule “some of them can be bent, others can be broken” told me a mentor in a famous movie.</p><p>Performances on day-to-day are an important part of the job, <strong>seconds matter</strong>. So to conclude I think we are going to give it a try for this consequent e-commerce project we are going to build in the next months. And we might go back to a container for PHP (and all the needed binaries) and one for Nginx (with HTTPS etc), that won’t be complex at all to switch back. I guess the decision will depend on how easy the onboarding will be using this approach.</p><p>It might be the right time for me to finish the full compliance of <a href="https://ezsystems.github.io/launchpad/index.html">eZ Launchpad</a> with pure Symfony project. Because when you have a container for PHP then you need to enter this container quite often (to run command) and this is where eZ Launchpad brings a lot of value. (EDIT: after re-reading this article I might start to do that ASAP! ;-))</p><p>Hope you liked it! Tell me what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=189e5a892439" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using eZ Launchpad with Platform.sh]]></title>
            <link>https://plopix.medium.com/using-ez-launchpad-with-platform-sh-6a9006c82d5?source=rss-f9c291e73d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a9006c82d5</guid>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[paas]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ez-platform]]></category>
            <dc:creator><![CDATA[Sébastien Morel]]></dc:creator>
            <pubDate>Wed, 26 Dec 2018 09:39:41 GMT</pubDate>
            <atom:updated>2018-12-26T09:55:48.972Z</atom:updated>
            <content:encoded><![CDATA[<h4>For eZ Platform Development with eZ Platform Cloud</h4><h4>Context</h4><p>Merry Christmas all, on vacation and still a bit jet-lagged I am waking up early and I am taking the time to write this article that could have followed this one: <a href="https://medium.com/@Plopix/ez-platform-cloud-and-ez-launchpad-dont-host-don-t-deploy-don-t-install-just-code-6140d75a439d">https://medium.com/@Plopix/ez-platform-cloud-and-ez-launchpad-dont-host-don-t-deploy-don-t-install-just-code-6140d75a439d</a></p><p>As you may know, I am a huge fan of <a href="https://php.net/">PHP</a>, <a href="https://symfony.com/">Symfony</a>, and <a href="https://ezplatform.com/">eZ Platform</a> along with <a href="https://docker.com/">Docker</a> and <a href="https://platform.sh/">Platform.sh</a>. eZ Platform is a Content Management System (CMS) fully based on Symfony (i.e: it does not just use few Symfony components, it is a full Symfony application using the framework). And <a href="https://ez.no/Products/eZ-Platform-Cloud">eZ Platform Cloud</a> is one of the <a href="https://platform.sh/solutions/software-vendors">White-Label PaaS for Platform.sh</a></p><p>I saw a tweet this morning about <a href="https://docs.platform.sh/gettingstarted/local/docksal.html">Docksal.io and Platform.sh</a>, and I decided to write this one to explain how we are using <a href="https://ezsystems.github.io/launchpad/">eZ Launchpad</a> for local development with Platform.sh and how it is simple.</p><blockquote><strong>@Platform.sh: </strong>I would be very proud to write or see a part of this article in your documentation.</blockquote><p>Let’s get started!</p><h4>eZ Launchpad Install</h4><p>eZ Launchpad approach is to stay as decoupled as possible from your development machine and your remote hosting whether you are Linux or Mac OSX. Installation is really simple:</p><pre>$ curl -LSs https://ezsystems.github.io/launchpad/install_curl.bash | bash</pre><p>Then you can just start to use it to initialize your eZ Platform project on top docker (<a href="https://medium.com/@Plopix/ez-platform-cloud-and-ez-launchpad-dont-host-don-t-deploy-don-t-install-just-code-6140d75a439d">see my previous article</a>)</p><pre>~/ez init</pre><p>or just create the docker stack based on an existing project</p><pre>git clone yourproject.git ezplatform; cd ezplatform; ~/ez create</pre><p>Done!</p><p>Now how to nicely work with Platform.sh</p><h4>Platform.sh integration</h4><p>First the .platform.app.yaml and the .platform generation, those two files are the key for Platform.sh.</p><ul><li>.platform folder describes <a href="https://docs.platform.sh/configuration/services.html">your services</a></li><li>.platform.app.yaml your application, <a href="https://docs.platform.sh/configuration/app-containers.html">the build, the deploy and more…</a></li></ul><p>To generate them, you just have to run</p><pre>~/ez platformsh:setup</pre><p>Launchpad will generate the files for you and you are then totally free to finetune them.</p><h4>Local development with Platform.sh</h4><p>First, let’s describe what do we mean here. Local development is ensured by the docker stack but what are the minimum day-to-day tasks that we need with our remote PaaS?</p><ul><li>Database synchronization (getting it from the PaaS to the local)</li><li>File storage synchronization (getting it from the PaaS to the local)</li><li>Deployment</li></ul><blockquote>We could also used <a href="https://docs.platform.sh/configuration/services.html#open-an-ssh-tunnel-directly">SSH tunnels</a>, but that is not the way we are doing it, we, as mentioned want to be as decoupled as possible. Then we want the whole project to work offline on our local.</blockquote><p>Thankfully Platform.sh provides a CLI that you probably already have, if you don’t</p><pre>curl -sS https://platform.sh/cli/installer | php</pre><p>So we want to automate actions, right? <strong>Makefile</strong>! Here are my 4 best friend targets:</p><pre># Makefile<br>PLATFORMSH := platform<br>EZ := ~/ez<br>GIT := git</pre><pre>.PHONY: reinitdb<br>reinitdb: <em>## Re initialize a fresh database<br>   </em>@$(EZ) importdata<br>   @$(EZ) sfrun cache:clear</pre><pre>.PHONY: sync-local-db-only<br>sync-local-db-only: <em>## Sync the local db ONLY<br>   </em>@$(PLATFORMSH) db:dump --gzip -f ezplatform.sql.gz -d data/ -y<br>   @$(MAKE) reinitdb</pre><pre>.PHONY: sync-local-storage<br>sync-local-storage: sync-local-db-only <em>## Sync the local db and storage<br>   </em>@$(PLATFORMSH) mount:download -m ezplatform/web/var --target=ezplatform/web/var/ -y</pre><pre>tag := master-$(shell date +%F-%H-%M-%S-%Z)<br>.PHONY: deploy-prod <em>## Tag and deploy on the master(prod) env<br></em>deploy-prod:<br>   $(GIT) tag -a $(tag) -m &#39;New Release&#39; master<br>   $(GIT) push origin $(tag)<br>   $(GIT) push platform +$(tag)~0:master</pre><p><strong>Explanations:</strong></p><pre>~/ez importdata</pre><p>This is an eZ Launchpad command that takes the data and the database (from the local data/folder) and imports it in the local docker stack. (~/ez dumpdata would do the opposite)</p><pre>~/ez sfrun cache:clear</pre><p>This runs the Symfony command (“<strong>s</strong>ym<strong>f</strong>ony <strong>run</strong>”): cache:clear</p><p>Yes, remember, you need to execute PHP from within your container (local docker stack) eZ Launchpad is a wrapper made to simplify that:</p><ul><li>~/ez sfrun something : to run bin/console something inside the container</li><li>~/ez comprun something : to run composer something inside the container</li><li>~/ez enter : to enter by default in the PHP container</li></ul><p>Now you know that the following is just straightforward, staying on the host (<em>i.e: you don’t that to go in the container</em>)</p><ul><li>We get the database dump in the data/folder and we import</li></ul><pre>platform db:dump --gzip -f ezplatform.sql.gz -d data/ -y<br>~/ez importdata</pre><ul><li>and we sync the storage</li></ul><pre>platform mount:download -m ezplatform/web/var --target=ezplatform/web/var/ -y</pre><blockquote>The last target deploy-prodis one automation to tag /push <strong>master</strong> in your code authority and push to Platform.sh to deploy.</blockquote><p>That’s it!</p><p>Many more things can be done using eZ Launchpad to rock your Developer eXperience, ~/ez list will give you an overview.</p><p>Hope you will try it!</p><p>See you!</p><p><a href="https://www.novactive.us/">https://www.novactive.us</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a9006c82d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eZ Platform Cloud and eZ Launchpad: don’t host, don’t deploy, don’t install: just code]]></title>
            <link>https://plopix.medium.com/ez-platform-cloud-and-ez-launchpad-dont-host-don-t-deploy-don-t-install-just-code-6140d75a439d?source=rss-f9c291e73d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/6140d75a439d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ez-platform]]></category>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[paas]]></category>
            <dc:creator><![CDATA[Sébastien Morel]]></dc:creator>
            <pubDate>Tue, 05 Dec 2017 17:34:25 GMT</pubDate>
            <atom:updated>2017-12-05T17:34:25.829Z</atom:updated>
            <content:encoded><![CDATA[<p>After more than 14 years working on web projects using PHP at Novactive, I can say that I have seen a lot of projects and a lot of ways to organize them. Among other technologies, we are expert on <a href="https://www.ezplatform.com/">eZ Platform</a> (and its predecessor eZ Publish). eZ Platform, as you might know, is a <strong>C</strong>ontent <strong>M</strong>anagement <strong>S</strong>ystem (CMS) fully based on <a href="https://symfony.com/">Symfony</a> (i.e: it does not just use few Symfony components, it is a full Symfony application using the framework). It’s a professional CMS and a development platform that comes with many features to make it <strong>robust</strong>, <strong>powerful</strong>, <strong>scalable</strong> and <strong>reliable</strong>.</p><p>When you instantiate a web project you might end up with those services:</p><ul><li>A <strong>web server</strong>: <a href="https://www.nginx.com/">Nginx</a> or <a href="https://httpd.apache.org/">Apache</a></li><li>A <strong>database</strong>: <a href="https://www.mysql.com/">MySQL</a> or <a href="https://mariadb.org/">MariaDB</a></li><li>An <strong>application cache</strong>: <a href="https://memcached.org/">Memcached</a> or <a href="https://redis.io/">Redis</a></li><li>A <strong>session storage</strong>: Memcached or Redis</li><li>A <strong>search engine</strong>: <a href="http://lucene.apache.org/solr/">Solr</a> or <a href="https://www.elastic.co/">ElasticSearch</a></li><li>A <strong>reverse proxy / HTTP Cache</strong>: <a href="https://varnish-cache.org/">Varnish</a></li><li>And <a href="http://php.net/manual/en/install.fpm.php"><strong>PHP-FPM</strong></a><strong> </strong>(as we are doing PHP)</li></ul><p>Those are the basics for me and not related to any CMS or framework. It could be different for you, of course you can install your CMS or eZ Platform with just Apache and MySQL on the same server, no reverse-proxy, no search-engine, the file system for application cache and session. As we focus on professional use cases, we usually prefer to rely on all those services (and not the just the basics). It is pretty common that you will also add:</p><ul><li>A <strong>message broker</strong> / queue system: <a href="https://www.rabbitmq.com/">RabbitMQ</a></li><li>A <strong>file storage</strong>: <a href="https://en.wikipedia.org/wiki/Network_File_System">NFS</a> or <a href="https://aws.amazon.com/s3/">AWS S3</a></li></ul><p>Having a lot of services is great, <strong>the more you decouple</strong>, <strong>the more and the easier you can scale</strong>. However it<strong> </strong>also means the installation and configuration is more complex.</p><p>Add to that that your projects probably requires:</p><ul><li>multiple <strong>developers</strong>, project <strong>managers</strong> and <strong>stakeholders</strong> working <strong>at the same time</strong>.</li><li><strong>developing</strong>, <strong>testing </strong>and <strong>delivering</strong> multiple <strong>features at the same time</strong>.</li></ul><p>You have to be organized to manage the different features and their releases by multiple team members. Thankfully, we have <a href="https://en.wikipedia.org/wiki/Git">Git</a> and <a href="https://github.com/">Github</a>, <a href="https://bitbucket.org/">Bitbucket</a> even <a href="https://about.gitlab.com/">Gitlab</a> to manage the source code of those features. That’s great, but what about everything else?</p><p>What about the development architecture? What about the hosting? How do you work comfortably/professionally with that many services?</p><p>I can hear you whispering: <a href="http://docker.com/"><strong>Docker</strong></a>! Yes Docker is the <strong>solution</strong>. At least a totally valid solution.</p><p>Recreating a complete architecture of services just with a “<em>docker-compose.yml</em>” file is just mind blowing. Thanks to <strong>Docker</strong> we can bootstrap the <strong>production-like architecture</strong> in 10min. In my opinion, that is perfect for developments.</p><p>More than that, with that approach you can run your(s) project(s) locally in the 2 main modes:</p><ul><li><strong>development</strong> mode: with all <strong>logs</strong> activated, symfony <strong>debugging</strong> <strong>tools</strong> on, and <strong>caches disabled</strong></li><li><strong>production</strong> mode: with all the <strong>optimizations</strong> and <strong>caches enabled</strong></li></ul><p>All of that <strong>on</strong> top of<strong> the same code base</strong>! No excuse to do not test your developments through Varnish or without cache enabled! (I am sure you know what I mean)</p><p>Creating the architecture is the easy part. <strong>As a lead developer</strong>, once it works you need to <strong>share it with your co-workers</strong> for them to bootstrap the project even faster than you did. That is not an easy task, it needs automations, logics, and processes. It can be challenging and time-consuming if you have not done it many times.</p><p>When it comes to <strong>Developer eXperience</strong>, the most important factor is the <strong>time to first success</strong>. The success happens when you get your development environment working with all the services.</p><p>Then we can differentiate 2 main use cases:</p><ul><li><strong>Initializing</strong> a new project from scratch.</li><li><strong>Sharing</strong> an already initialized project with a new developer and getting him ready to contribute.</li></ul><p>In those two cases, the “first success” (having the dev environment working) should be easy, you should not even think about it.<strong> That is the role of </strong><a href="https://ezsystems.github.io/launchpad/"><strong>eZ Launchpad</strong></a><strong>!</strong></p><p><strong>eZ Launchpad</strong> has been built to <strong>optimize</strong> and <strong>simplify</strong> those two cases, but not only.</p><p><strong><em>Question</em></strong>: how simple is it to work with Docker? How do you check logs of the different services, how do you run a <em>php</em> command inside the <em>php container </em>(bad idea to install SSH on a container for instance), how do you <em>clear the cache</em>, <em>run composer</em> on the good container, etc? eZ Launchpad is made to simplify all of that for you.</p><p><strong>eZ Launchpad</strong> behaves as a <strong>wrapper</strong> between <strong>you </strong>and <strong>Docker</strong> to save you(r) time.</p><p>With eZ Launchpad you can get your Docker stack up and running, and ready for real development in just a few minutes. (<a href="https://ezsystems.github.io/launchpad/">see for yourself</a>)</p><p>Plus, <strong>eZ Launchpad</strong> is ready to <strong>wire bonus services</strong> to improve the <strong>Developer eXperience</strong>. Then by default you will get:</p><ul><li>Mailcatcher</li><li>Redis/Memcache Admin</li><li>Adminer</li><li><a href="https://ezsystems.github.io/launchpad/images/puml/LEMP_architecture.png"><em>Full dev architecture is here</em></a></li></ul><p>Then let’s recap here:</p><ul><li>Thanks to <strong>Docker</strong> and <strong>eZ Launchpad</strong> we can <strong>bootstrap</strong> and <strong>share</strong> a eZ Platform/Symfony <strong>project</strong> with a complete architecture.</li><li>Thanks to <strong>Git</strong> we can <strong>organize</strong> the <strong>source</strong> <strong>code</strong> to work on <strong>features</strong>, <strong>share</strong> the code, <strong>merge</strong> etc.</li></ul><p><strong>As a developer</strong> you can test what you are doing, you can switch branches, but what about the project managers or your clients? eZ Launchpad will certainly help to bootstrap your project on your favorite hosting provider using the 2 commands required to get your project up and running. But it feels complex to scale <strong>by features</strong>, how do you sync the data and what about the URLs to reach those environments?</p><p>Plus, remember eZ Launchpad is for development and not for production. For <strong>staging</strong> or <strong>pre-production</strong> you want a <strong>production</strong>-<strong>equivalent environment to secure your QA</strong>.</p><p>One solution would be to build Docker images based on the images used for developments (but with no <em>mount</em>) and use Docker in production. <strong>That is a perfectly valid and working solution</strong>. But:</p><ul><li>it does not really help to test different features in progress, to test Pull Request on a real production-equivalent environments.</li><li>that imposes you to manage the production yourself with Docker, and you might not want to do that for many reasons.</li></ul><p>That is when I introduce you to <a href="https://platform.sh/"><strong>Platform.sh</strong></a>! <strong>Platform.sh</strong> is <a href="https://en.wikipedia.org/wiki/Platform_as_a_service"><strong>PaaS</strong></a>, <strong>P</strong>latform <strong>a</strong>s <strong>a</strong> <strong>S</strong>ervice, it is a <strong>continuous deployment cloud hosting solution</strong> for web applications.</p><p>With Platform.sh <strong>a branch equals an environment</strong>. Better, when a Pull Request is created Platform.sh clones the parent environment branch (ex: <em>master</em>) and creates a new environment for your clients/project managers to test the PR with its own URL. You get a replica of the application on top of the PR including all the data storages, the databases and the services up-to-date!</p><p>It means <strong>you don’t deploy anymore!</strong> <strong>You just <em>push</em> (Git)</strong>, that is it!</p><p>And guess what? <strong>eZ Systems teamed up</strong> with them to unleash <a href="https://ez.no/Products/eZ-Platform-Cloud"><strong>eZ Platform Cloud</strong></a>!</p><p>And because that is not cool enough, <strong>eZ Launchpad is perfectly aware of Platform.sh configuration</strong>.</p><p>What does that mean? That means that if you are using <strong>eZ Launchpad</strong>, you can, “kind of” <strong>convert</strong> your <strong>Docker Compose file</strong> to a <strong>Platform.sh configuration file</strong>.</p><p>Then to sum up, in less than 15 minutes, you can:</p><ul><li>Install eZ Launchpad</li><li>Initialize a new project</li><li>Enable Platform.sh configuration through eZ Launchpad</li><li>Push on git to transparently deploy</li></ul><p><strong>You don’t install, you don’t host, you don’t deploy, you just code!</strong></p><p>And with eZ Platform Cloud you get the power of eZ Platform Enterprise(and all services related) plus Platform.sh!</p><ul><li>High-Performance and High-Availability: <strong>99.99% uptime</strong></li><li>Great SLA and a centralized support <strong>application</strong> and <strong>infrastructure.</strong></li><li>Triple redundancy, <strong>performances</strong>, <strong>security</strong></li><li>And more!</li></ul><p>This is the way to go for me! And what I wanted to share! Now, you definitively have to try <strong>eZ Platform</strong> with e<strong>Z Launchpad</strong>, <strong>Platform.sh</strong> and <strong>eZ Platform Cloud</strong>!</p><p>And if you have a project to realize and are looking for help, we will love to accompany you in <strong>Europe</strong> with Novactive based in <strong>Paris</strong> and <strong>Toulon</strong> and in the <strong>U.S.</strong> here in <strong>San Francisco, CA</strong>.</p><p>See you!</p><p><a href="https://www.novactive.us/">https://www.novactive.us</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6140d75a439d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>