<?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 Thierry Feuzeu on Medium]]></title>
        <description><![CDATA[Stories by Thierry Feuzeu on Medium]]></description>
        <link>https://medium.com/@thierry.feuzeu?source=rss-a1e957e5b61b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Kgr6aJiysq2hnnASjpT0Rg.png</url>
            <title>Stories by Thierry Feuzeu on Medium</title>
            <link>https://medium.com/@thierry.feuzeu?source=rss-a1e957e5b61b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 17:47:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thierry.feuzeu/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[Create complex UI with a class library in PHP]]></title>
            <link>https://blog.stackademic.com/create-complex-ui-with-a-class-library-in-php-e29274c4aadf?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e29274c4aadf</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ui-component]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[html-builder]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 21:25:52 GMT</pubDate>
            <atom:updated>2026-10-13T23:23:13.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60WvpqhE2M7kywRqcE8iuw.jpeg" /></figure><p>Despite the rise of JavaScript frameworks like React and Angular, building the UI on the backend is still a common feature in many web applications. This is generally done with a template library, like <a href="https://twig.symfony.com/">Twig</a>, <a href="https://laravel.com/framework/docs/blade">Blade</a> or <a href="https://latte.nette.org/">Latte</a>, and often using a different language which is close or related to the main application language. A template engine then converts the template code into the application language, and generally caches the generated code for further reuse.</p><p>In the PHP ecosystem, there are many attempts to build application UIs using a class library.</p><p>Some of the most popular complements a template library. <a href="https://spatie.be/docs/laravel-html">spatie/html</a> extends <a href="https://laravel.com/framework/docs/blade">Laravel Blade</a> with functions to build HTML elements. <a href="https://symfony.com/doc/current/forms.html">Symfony Forms</a> and <a href="https://doc.nette.org/fr/forms">Nette Forms</a> can build forms, then validate and process their values.</p><p>Less known and less used, there are other PHP packages whose purpose is to build an application UI using a class library. <a href="https://www.atk4.org/">ATK UI</a>, <a href="https://viewi.net/">Viewi</a>, <a href="https://github.com/ui-awesome/html">ui-awesome/html</a>, <a href="https://github.com/DanielEScherzer/html-builder">danielescherzer/html-builder</a> and <a href="https://github.com/siriusphp/html">Sirius HTML</a> are a few examples of such libraries.</p><p>However, they don’t match the advanced features of template libraries like Blade or Twig. Even when providing a fluent API, generally those libraries can only create chunks of HTML or individual HTML components, without being able to tie them together into a complete UI block. The user then needs to complement them with a template engine or plain PHP calls for string concatenation, iterative or conditional rendering.</p><h3>The HTML Builder library</h3><p><a href="https://github.com/lagdo/html-builder">HTML Builder</a> is a PHP library that provides classes to represent the HTML components, as well as an API to build UIs using those classes. A UI is built using a call tree, where each component receives its children as parameters. HTML tags are created by calling methods named after the tags, while attributes are set using methods named set followed by the attribute name in PascalCase.</p><pre>    $this-&gt;html-&gt;div(<br>        $this-&gt;html-&gt;div(<br>            $this-&gt;html-&gt;label($this-&gt;html-&gt;text(&#39;Collation&#39;))<br>                -&gt;setFor(&#39;collation&#39;)<br>        )-&gt;setStyle(&#39;width: 30%;&#39;),<br>        $this-&gt;html-&gt;div(<br>            $this-&gt;html-&gt;select(<br>                $this-&gt;html-&gt;option(&#39;(collation)&#39;)<br>                    -&gt;setValue(&#39;&#39;)<br>                    -&gt;setSelected(true),<br>                $this-&gt;html-&gt;each($collations, fn(array $groupCollations, $group) =&gt;<br>                    $this-&gt;html-&gt;list(<br>                        $this-&gt;html-&gt;when($group === &#39;&#39;, fn() =&gt;<br>                            $this-&gt;html-&gt;each($groupCollations, $this-&gt;html-&gt;option(...))<br>                        ),<br>                        $this-&gt;html-&gt;when($group !== &#39;&#39;, fn() =&gt;<br>                            $this-&gt;html-&gt;optgroup(<br>                                $this-&gt;html-&gt;each($groupCollations, $this-&gt;html-&gt;option(...))<br>                            )-&gt;setLabel($group)<br>                        )<br>                    )<br>                )<br>            )-&gt;setName(&#39;collation&#39;)<br>        )-&gt;setStyle(&#39;width: 70%;&#39;)<br>    )-&gt;setStyle(&#39;display: flex; justify-content: space-between;&#39;);</pre><p>This is the same template, built with Twig.</p><pre>&lt;div style=&quot;display: flex; justify-content: space-between;&quot;&gt;<br>    &lt;div style=&quot;width: 30%;&quot;&gt;<br>        &lt;label for=&quot;collation&quot;&gt;Collation&lt;/label&gt;<br>    &lt;/div&gt;<br>    &lt;div style=&quot;width: 70%;&quot;&gt;<br>        &lt;select name=&quot;collation&quot;&gt;<br>            &lt;option value=&quot;&quot; selected&gt;(collation)&lt;/option&gt;<br>            {% for group, groupCollations in groups %}<br>                {% if group == &#39;&#39; %}<br>                    {% for collation in groupCollations %}<br>                        &lt;option&gt;{{ collation }}&lt;/option&gt;<br>                    {% endfor %}<br>                {% else %}<br>                    &lt;optgroup label=&quot;{{ group }}&quot;&gt;<br>                        {% for collation in groupCollations %}<br>                            &lt;option&gt;{{ collation }}&lt;/option&gt;<br>                        {% endfor %}<br>                    &lt;/optgroup&gt;<br>                {% endif %}<br>            {% endfor %}<br>        &lt;/select&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><h3>The virtual components</h3><p>What actually makes the HTML Builder library as powerful as a template library, is its virtual components.</p><p>A virtual component takes application data as input, and generates zero, one or more components as output. It generates no additional HTML tag, so its output is only composed of those of the generated components.</p><p>There is a bidirectional relation between virtual and real components. A real component can contain either real or virtual components as children, and a virtual component can generate a collection of real and virtual components.</p><p>Virtual components enable the HTML Builder library to generate HTML elements dynamically, a feature not available in the libraries mentioned above.</p><h3>The types of virtual components</h3><p>The HTML Builder library provides 5 types of virtual components.</p><blockquote>Note: a closure passed to a virtual component must return a single component, which can be real or virtual.</blockquote><h4>The When component</h4><p>The When component mimics the if clause of template languages. It takes a boolean condition and a closure as parameters, and calls the closure only when the condition is true.</p><pre>$this-&gt;html-&gt;when($user-&gt;isLoggedIn,<br>    fn() =&gt; $this-&gt;html-&gt;div($this-&gt;html-&gt;text($user-&gt;email)));</pre><h4>The List component</h4><p>The List component groups a set of components into a single one. It then allows to pass a list of components in places where a single component is expected, for example as the return value of a function.</p><pre>$this-&gt;html-&gt;when($user-&gt;isLoggedIn,<br>    fn() =&gt; $this-&gt;html-&gt;list(<br>        $this-&gt;html-&gt;b($this-&gt;html-&gt;text(&#39;Welcome &#39;)),<br>        $this-&gt;html-&gt;div($this-&gt;html-&gt;text($user-&gt;email))<br>    );</pre><h4>The Pick component</h4><p>The Pick component mimics the PHP switch clause. It takes multiple When components as input, and calls the closure provided by the first true condition.</p><pre>$this-&gt;html-&gt;pick(<br>    $this-&gt;html-&gt;when($user === null,<br>        fn() =&gt; $this-&gt;html-&gt;html(&#39;Welcome&#39;)),<br>    $this-&gt;html-&gt;when($user-&gt;isAdmin,<br>        fn() =&gt; $this-&gt;html-&gt;html(&quot;Welcome&amp;nbsp;&lt;b&gt;{$user-&gt;name}&lt;/b&gt;&quot;)),<br>    $this-&gt;html-&gt;when(true,<br>        fn() =&gt; $this-&gt;html-&gt;html(&quot;Welcome&amp;nbsp;{$user-&gt;name}&quot;))<br>);</pre><h4>The Each component</h4><p>The Each component takes an array of items and a closure as parameters, and calls the closure with each item in the array. It then generates the same number of components, each of which can be either real or virtual.</p><pre>$this-&gt;html-&gt;select(<br>    $this-&gt;html-&gt;option(&#39;(Default)&#39;)-&gt;setValue(0),<br>    $this-&gt;html-&gt;each($choices,<br>        fn($choice) =&gt; $this-&gt;html-&gt;option($choice-&gt;label))<br>);</pre><p>The Each component can also take an iterator or a generator as parameter, and the closure also accepts the array key value as second parameter.</p><pre>$this-&gt;html-&gt;select(<br>    $this-&gt;html-&gt;option(&#39;(Default)&#39;)-&gt;setValue(0),<br>    $this-&gt;html-&gt;each($choices,<br>        fn($choice, $id) =&gt; $this-&gt;html-&gt;option($choice-&gt;label)-&gt;setValue($id))<br>);</pre><h4>The Loop component</h4><p>The Loop component is the same as the Each component, but its second parameter is a LoopItem object, which provides various information about the current loop.</p><pre>$this-&gt;html-&gt;select(<br>    $this-&gt;html-&gt;option(&#39;(Default)&#39;)-&gt;setValue(0),<br>    $this-&gt;html-&gt;loop($choices,<br>        fn($choice, $loop) =&gt; $this-&gt;list(<br>            $this-&gt;when($loop-&gt;current-&gt;group !== $loop-&gt;prev?-&gt;group,<br>                fn() =&gt; $this-&gt;html-&gt;option($loop-&gt;current-&gt;group)<br>                    -&gt;setClass(&#39;group-title disabled&#39;)),<br>            $this-&gt;html-&gt;option($choice-&gt;label)-&gt;setValue($id))<br>        )<br>);</pre><blockquote>Note: The Loop component was inspired by <a href="https://symfony.com/blog/new-in-symfony-8-1-a-new-for-loop-for-twig-4-0">this article on Twig</a>.</blockquote><h3>Comparison with template engines</h3><p>The HTML Builder library combines a fluent PHP API with a lightweight, object-oriented approach to HTML generation.</p><p>Its virtual components support dynamic content while deferring the execution of closures until rendering. This keeps UI construction entirely within PHP, using a consistent fluent API from start to finish, without requiring a separate template compilation step.</p><p>The combination of regular and virtual components provides the building blocks needed to implement the main features commonly found in template engines, including conditional rendering and iteration, while preserving the fluent API. Combined with PHP’s object-oriented features, such as inheritance, traits, method overloading, and composition, this approach offers a flexible way to structure and reuse UI code.</p><p>Like template engines, theHTML Builder library can also be extended with custom functions to meet application-specific needs.</p><h4>Why use HTML Builder?</h4><p>When using the HTML Builder library, the application UI is organized as a library of PHP classes rather than a collection of template files. This makes the UI independent of any particular application framework and eliminates the need for a separate template engine.</p><p>UI classes can accept structured objects and domain-specific data types instead of relying solely on simple arrays. This allows the interfaces between the UI and other application components to be defined more explicitly, improving separation of concerns and making dependencies easier to understand.</p><p>A class-based UI can also benefit from familiar software engineering practices, including encapsulation, inheritance, code reuse, and unit testing. For applications where the UI is maintained as part of the codebase, this approach can make the code easier to organize, maintain, and test.</p><h4>What changes with HTML Builder?</h4><p>Template engines commonly compile templates into PHP code and cache the compiled result for reuse. This reduces the overhead of processing templates repeatedly and can provide a performance advantage over an object-based approach to HTML generation.</p><p>HTML Builder instantiates objects for HTML components and makes use of features such as magic methods, closures, and method calls to compose the final output. These mechanisms introduce some runtime overhead compared with executing pre-compiled PHP code.</p><p>However, performance depends on the implementation, the structure of the UI, and the amount of work involved in rendering it. The trade-off is an approach that emphasizes object-oriented composition, extensibility, and code reuse rather than minimizing runtime overhead.</p><p>Some template engines also provide a sandbox that allows untrusted templates to be executed with restricted capabilities, improving security. Developers can define which functions templates are allowed to call.<br>This feature is particularly useful when an application needs to render templates provided by third parties.</p><p>HTML Builder does not provide a sandbox, as it is designed to build HTML directly from PHP code rather than to execute untrusted templates. Its UI classes are intended to be part of the application’s codebase, not to serve as a restricted execution environment for externally supplied templates.</p><h3>The UI Builder library</h3><p>The <a href="https://github.com/lagdo/ui-builder">UI Builder</a> library extends the HTML Builder library with functions for creating UI components based on CSS frameworks. It provides a set of primitives for creating components such as buttons, cards, tabs, pagination, and more, as well as configuring their properties.</p><p>The UI Builder library is currently used to build the UI of the <a href="https://github.com/lagdo/jaxon-dbadmin">Jaxon DbAdmin</a> application, and the example below is taken from its codebase.</p><pre>$this-&gt;html-&gt;build(<br>    $this-&gt;html-&gt;buttonGroup(<br>        $this-&gt;html-&gt;button(<br>            $this-&gt;html-&gt;text($this-&gt;trans-&gt;lang(&#39;Columns &#39;)),<br>            $this-&gt;html-&gt;when($columnCount &gt; 0, fn() =&gt;<br>                $this-&gt;html-&gt;badge(&quot;$columnCount&quot;)-&gt;primary())<br>        )-&gt;outline()<br>            -&gt;secondary()<br>            -&gt;fullWidth(),<br>        $this-&gt;html-&gt;button(<br>            $this-&gt;html-&gt;text($this-&gt;trans-&gt;lang(&#39;Filters &#39;)),<br>            $this-&gt;html-&gt;when($filterCount &gt; 0, fn() =&gt;<br>                $this-&gt;html-&gt;badge(&quot;$filterCount&quot;)-&gt;primary())<br>        )-&gt;outline()<br>            -&gt;secondary()<br>            -&gt;fullWidth(),<br>        $this-&gt;html-&gt;button(<br>            $this-&gt;html-&gt;text($this-&gt;trans-&gt;lang(&#39;Order &#39;)),<br>            $this-&gt;html-&gt;when($sorterCount &gt; 0, fn() =&gt;<br>                $this-&gt;html-&gt;badge(&quot;$sorterCount&quot;)-&gt;primary())<br>        )-&gt;outline()<br>            -&gt;secondary()<br>            -&gt;fullWidth()<br>    )-&gt;fullWidth()<br>);</pre><p>The UI Builder library is separated into multiple PHP packages.</p><p>The <a href="https://github.com/lagdo/ui-builder">lagdo/ui-builder</a> package provides the BuilderInterface interface, which defines the functions that each builder must implement. It also provides base classes for UI components and implements a common set of functions shared by the different builders.</p><p>Each supported CSS framework has its own package, which implements the Builder class and the corresponding UI component classes. Each component class defines how the component’s HTML is generated for the target framework, using the functions provided by the <a href="https://github.com/lagdo/ui-builder">lagdo/ui-builder</a> and <a href="https://github.com/lagdo/html-builder">lagdo/html-builder</a> packages.</p><p>The framework-specific Builder class extends the AbstractBuilder class provided by the UI Builder package and only needs to specify the names of the component classes it uses.</p><p>The following CSS frameworks are currently supported:<br>- <a href="https://github.com/lagdo/ui-builder-bootstrap5">Bootstrap 5</a><br>- <a href="https://github.com/lagdo/ui-builder-bootstrap4">Bootstrap 4</a></p><p>The <a href="https://github.com/lagdo/ui-builder-bootstrap3">Bootstrap 3</a> package is deprecated.</p><p>The packages for <a href="https://github.com/lagdo/ui-builder-tailwind">Tailwind CSS</a> and <a href="https://github.com/lagdo/ui-builder-bulma">Bulma</a> are under development and will be available soon.</p><h3>Closing thoughts</h3><p>Generating an application UI entirely in PHP has always been challenging. PHP libraries designed for this purpose have traditionally lacked many of the features offered by template engines, often requiring developers to supplement them with a template engine or direct PHP calls.</p><p>Thanks to its virtual components, the <a href="https://github.com/lagdo/html-builder">HTML Builder</a> library bridges this gap. Its fluent API and methods named after HTML tags make it easier to build complex application UIs entirely in PHP.</p><p>The <a href="https://github.com/lagdo/ui-builder">UI Builder</a> library takes this approach a step further by extending the HTML Builder library with higher-level UI components, such as buttons, cards, tabs, and pagination. Framework-specific packages generate the corresponding HTML for CSS frameworks such as Bootstrap, Tailwind CSS, and Bulma.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e29274c4aadf" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/create-complex-ui-with-a-class-library-in-php-e29274c4aadf">Create complex UI with a class library in PHP</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jaxon DbAdmin: PHP finally gets a next-gen database manager]]></title>
            <link>https://medium.com/@thierry.feuzeu/jaxon-dbadmin-php-finally-gets-a-next-gen-database-manager-bd6aebd25e46?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd6aebd25e46</guid>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[ajax]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 01:59:17 GMT</pubDate>
            <atom:updated>2026-10-11T00:33:25.238Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1RYd9S-G4N0goFmSt3FZQ.png" /></figure><p>The PHP ecosystem has gifted the IT world with two of the most widely used open-source database management tools: <a href="https://adminer.org/">Adminer</a> and <a href="https://www.phpmyadmin.net/">PhpMyAdmin</a>, each having millions of monthly downloads. However, newer solutions have emerged to provide advanced features that these traditional tools do not natively offer, such as simultaneous multi-database browsing, data masking, advanced users and credentials management, audit logging, and modern UI/UX. Alternatives like <a href="https://dbeaver.io/">DBeaver</a>, <a href="https://www.dbgate.io/">DbGate</a>, <a href="https://www.bytebase.com/">ByteBase</a>, and the more recent <a href="https://github.com/TabularisDB/tabularis">Tabularis</a> and <a href="https://github.com/t8y2/dbx">DBx</a>, just to name those with an open source license, deliver these capabilities. Available as web or desktop applications, their user interfaces are built using modern JavaScript frameworks like React.</p><p>Today, the Jaxon DbAdmin web application bridges this gap. It positions itself as a modern database management tool built with PHP, delivering the same high-level features as the most advanced alternatives on the market.<br>While the foundational <a href="https://github.com/lagdo/jaxon-dbadmin/releases?page=2#release-v0.32.0">0.32.0 release</a> introduced an extensive list of changes, fixes, and architectural improvements, subsequent releases have refined the platform. The features highlighted in this article are available in <a href="https://github.com/lagdo/jaxon-dbadmin/releases?page=1#release-v0.35.1">version 0.35.1</a>, the latest release at the time of writing. Finally, we will also take a look at the main features planned for upcoming releases.</p><h4>The Jaxon DbAdmin applications</h4><p>Jaxon DbAdmin is provided as a <a href="https://www.jaxon-php.org/docs/v5x/extensions/packages.html">Jaxon package</a>, which means it implements both the application backend and frontend, and it needs to be installed in an application framework.</p><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/01.-Features-and-current-status">features and current status</a>.</blockquote><p>The previous Jaxon DbAdmin releases shipped with a single ready-to-use application built with Laravel. There are now three of them, respectively built with the <a href="https://github.com/lagdo/dbadmin-app-laravel">Laravel</a>, <a href="https://github.com/lagdo/dbadmin-app-symfony">Symfony</a> and <a href="https://github.com/lagdo/dbadmin-app-slim">Slim</a> PHP frameworks.</p><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/02.-Installation">installation documentation</a>.</blockquote><p>The user management and authentication feature in Jaxon DbAdmin is provided by the framework it is installed on. Supporting multiple different frameworks then allows the users to choose their preferred authentication strategy and tools, depending on their needs. The Laravel, Symfony and Slim frameworks are able to implement various user authentication strategies, from the most simple to the most advanced.</p><p>The Jaxon DbAdmin applications include a default authentication feature where the user accounts are stored in a database for Laravel and Symfony, or in a json file for Slim.</p><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/05.-Authentication">default authentication documentation</a>.</blockquote><p>Althought they are based on different frameworks, the Jaxon DbAdmin applications share the same configuration options and files. The config options are separated into three files, app.php, servers.php and foreigns.php. In the app.php and foreigns.php config files, some options values are provided as closures or anonymous classes.</p><p>The servers.php file can also be provided in json or yaml format. In that case the file is renamed to servers.json, servers.yaml or servers.yml.</p><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/04.-Configuration-files">configuration documentation</a>.</blockquote><p>The Jaxon DbAdmin <a href="https://hub.docker.com/r/lagdo/jaxon-dbadmin">Docker images</a> are also updated, and they are now tagged both with the framework name and their version number.</p><h4>Database secrets management</h4><p>The previous releases already allow the users to store their database credentials in a secret management server, instead of the default .env.dbadmin file.</p><p>The latest release now natively supports 6 secret management services:</p><ul><li><a href="https://infisical.com/">Infisical</a></li><li><a href="https://aws.amazon.com/secrets-manager">AWS Secrets Manager</a></li><li><a href="https://cloud.google.com/security/products/secret-manager">GCP Secret Manager</a></li><li><a href="https://openbao.org/">OpenBao</a> (compatible with <a href="https://www.hashicorp.com/fr/products/vault">HashiCorp Vault</a>)</li><li><a href="https://azure.microsoft.com/fr-fr/products/key-vault">Azure Key Vault</a></li><li><a href="https://www.alibabacloud.com/help/en/kms">Alibaba Key Management Service</a></li></ul><p>Using a secret manager requires two options in the app.php config file.<br>The secret.reader option defines the name of the class implementing the service client, and the secret.key defines a class with a function returning the secret location for a given user.</p><pre>    &#39;secret&#39; =&gt; [<br>        &#39;reader&#39; =&gt; Provider\Secret\InfisicalConfigProvider::class,<br>        &#39;key&#39; =&gt; fn() =&gt; new class implements Provider\Secret\KeyBuilderInterface {<br>            public function build(string $prefix, string $option = &#39;&#39;): string<br>            {<br>                // $username = Auth::userId(); // Use this to customize the key.<br>                return &quot;users.{$prefix}.{$option}&quot;;<br>            }<br>        },<br>    ],</pre><p>Each secret manager also defines custom options to be provided in the .env.dbadmin file, and optionally a procedure to setup the client.<br>Jaxon DbAdmin will query the secret service for database credentials on each user request, and will never save any secret locally, not even in a cache.</p><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/08.-Using-a-secret-manager-service">secret service configuration</a>.</blockquote><h4>Multi-tab navigation</h4><p>The list of database servers a Jaxon DbAdmin user can connect to is configured on the server. That list can be customized for each user, and the servers he is allowed to connect to will be displayed in a dropdown list.</p><p>Jaxon DbAdmin allows the user to open multiple tabs, each connected to a chosen database. Each tab can be renamed, and by default a tab is named after the database it is connected to. Connecting to a different database automatically rename the tab accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90SNBmdEx-iNrxRtfAm0fA.png" /><figcaption>Jaxon DbAdmin tabs</figcaption></figure><p>When connected to a database, the Query Editor window also allows the user to open multiple tabs. It is convenient when the user needs to run multiple queries on the same database.</p><p>The application window and Query Editor tabs can be saved in the user preferences. They will the be automatically recreated anytime the user opens the application.</p><h4>The Query Editor and Query Builder</h4><p>Similar to Adminer, Jaxon DbAdmin provides two tools to query database tables: the Query Editor and the Query Builder.</p><p>The Query Editor allows the user to manually edit, then execute SQL queries. As stated earlier, multiple editor tabs can be opened on the same database. The user can also choose its preferred editor between the <a href="https://codemirror.net/">CodeMirror 6</a> and <a href="https://ace.c9.io/">Ace</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uhg4CkP3KMdeyHuWtcOp9w.png" /><figcaption>Jaxon DbAdmin query editor</figcaption></figure><p>In addition to SQL syntax highlighting and code completion, the Query Editor also provides code completion on the connected database tables and columns names.</p><p>The Query Builder is a visual builder for database queries, which also supports querying and editing table data, and editing table definition.</p><p>The Query Builder displays the selected table rows in a paginated list. Various buttons and dialogs allow the user to select the columns to be displayed, filter rows on column values, and change the results ordering. The corresponding SQL query is displayed in a read-only field, with syntax highlighting enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sp50GQgAJn4S2qhSCT4f1w.png" /><figcaption>Jaxon DbAdmin query builder rows</figcaption></figure><p>Each data row can be edited in a dialog where each column value is displayed in an HTML input field corresponding to the column type.<br>The same dialog can be use to insert a new row in the table.</p><p>The Query Builder can also display a table definition, in a page with the table columns, indexes, foreign keys and triggers. From there, the table definition can be altered, in a page that will allow the user to change the table name and properties, and edit, delete or add columns in the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6tMZYicKL7D7nlpzq6G1Pg.png" /><figcaption>Jaxon DbAdmin query builder table edit</figcaption></figure><p>When editing row data or table definition, the corresponding SQL query can be displayed for prior validation, and even copied to the Query Editor.</p><h4>The foreign keys</h4><p>In the paginated list of rows of a table, when a column is a foreign key, each value is displayed in a link. A click on that link will move the page to the referenced table, and add a filter on the referenced column and value, so only the referenced row is showed.</p><p>When a table has one or more foreign keys, a toggle button labelled Foreigns is added on the page. When this button is enabled, the values from the first column with a string type in the referenced table are fetched and displayed instead of the actual column values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPzFZlBJFs_48zZPXVBAwQ.png" /><figcaption>Jaxon DbAdmin query builder foreigns</figcaption></figure><p>The SQL queries for fetching the referenced values can be customized in the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/04.-Configuration-files">foreigns.php</a> config file.</p><pre>return [<br>    &#39;dbadmin-mariadb&#39; =&gt; [<br>        &#39;employees&#39; =&gt; [<br>            &#39;employees&#39; =&gt; [<br>                &#39;emp_no&#39; =&gt; [<br>                    &#39;select&#39; =&gt; fn(int $textLength) =&gt; &quot;SUBSTR(CONCAT(first_name, &#39; &#39;, last_name), 1, $textLength)&quot;,<br>                    &#39;search&#39; =&gt; fn(string $search) =&gt; &quot;LOWER(first_name) LIKE $search OR LOWER(last_name) LIKE $search&quot;,<br>                ],<br>            ],<br>        ],<br>    ],<br>];</pre><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/09.-Foreign-fields-in-tables">foreign fields documentation</a>.</blockquote><h4>File storage for database import and export</h4><p>The database import and export function rely on the <a href="https://flysystem.thephpleague.com/">FlySystem</a> package for file storage. They are then able to store the SQL files on a any of the supported storage types.</p><p>The SQL files locations are user dependent, which means a user cannot get access to another user files from his account, event when knowing its name. This also apply to the file URL for database export. It is valid only for the user who made the export.</p><blockquote>Read the <a href="https://github.com/lagdo/jaxon-dbadmin/wiki/10.-Data-import-and-export">data import and export documentation</a>.</blockquote><h4>Input streaming in database import</h4><p>Generally, the imported files are loaded into the application memory before the SQL queries they contain are executed. The application then needs to have enough available memory to be able to store the entire file. In Adminer for example, the PHP memory limit is updated when processing the imported file.</p><p>Jaxon DbAdmin introduces a new Query Processor, with a new file processing model where the file lines are streamed in input, and the corresponding queries are streamed in output. This results in a dramatic reduction in memory usage, since only a few input lines and a single SQL query are kept in memory at the same same time.</p><p>This screenshot shows how the lines stream in and the queries stream out the Query Processor, on a few lines file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sGrw_X9ARicZGTkUGoCx-g.png" /><figcaption>Jaxon DbAdmin query splitter</figcaption></figure><p>While sequential execution within the new Query Processor can increase total execution time, this challenge is easily solved by modern PHP architectures. By leveraging framework workers, time-consuming queries can be handled asynchronously. This feature will be introduced in an upcoming release.</p><h4>Audit logging</h4><p>Jaxon DbAdmin can be configured to save all the executed queries in a dedicated database. These queries can then be visualized in a separate audit logging page with restricted access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a5Flqti-v8ozZlrHPh1mIw.png" /><figcaption>Jaxon DbAdmin audit logs</figcaption></figure><p>The latest releases feature an extension of the data Jaxon DbAdmin records in the audit logs. They now include the client IP, the user agent, and generated ids for the HTTP session and request, the database driver and options, the query code, result, timestamp and duration, the error code and message when the query execution fails, the number of returned or affected rows when the query execution succeeds, and of course, the user who executed the query.</p><blockquote>Note: some of the fields still need to be filled or displayed in the audit logs page.</blockquote><h3>The new application architecture</h3><p>Although running behind the scenes, the new application architecture is the foundation designed to make the implementation of all other features both simple and reliable.</p><h4>The database drivers</h4><p>Since its early releases, the database features are implemented in separate packages:</p><ul><li><a href="https://github.com/lagdo/dbadmin-driver">https://github.com/lagdo/dbadmin-driver</a>: common classes and interfaces for the database drivers.</li><li><a href="https://github.com/lagdo/dbadmin-driver-pgsql">https://github.com/lagdo/dbadmin-driver-pgsql</a>: the database driver for PostgreSQL.</li><li><a href="https://github.com/lagdo/dbadmin-driver-mysql">https://github.com/lagdo/dbadmin-driver-mysql</a>: the database driver for MySQL and MariaDB.</li><li><a href="https://github.com/lagdo/dbadmin-driver-sqlite">https://github.com/lagdo/dbadmin-driver-sqlite</a>: the database driver for SQLite.</li></ul><p>Today, the drivers have evolved to a simpler model where their features are separated into query generation and query execution. The query execution part takes a raw query as input, passes it to the database server, and, depending on the query type and the execution results, returns the appropriate set of data.</p><p>With the exception of a few specific cases, the DDL, DML and DQL functions now generate and return a set of SQL queries, which will then be executed in a separate call. Prior to execution, the generated query can be presented to the user for validation, editing, or even storage for future reuse.</p><p>The usage of DTOs has also been generalized. Instead of arrays or strings, the drivers functions now receive DTOs as input and returns other DTOs as output.</p><p>As stated before, the database features come from Adminer. It means that the actual calls to the database servers, for example to read the list of tables in a database, still run code inherited from Adminer. That code is eventually improved to adapt to PHP 8 changes, and return data in DTOs instead of arrays.</p><h4>The database support layer</h4><p>On top of the database drivers, a pluggable support layer is introduced, with many new features. The timer for query duration computation and audit logs storage are modules that are plugged into the driver proxy, and automatically called before and after every query execution. They take the query SQL code and results as parameters.</p><p>In addition to the drivers DTOs, another set of DTOs is provided to carry the data between the UI components and the driver. So a database function now takes the user data as input in a UI DTO, converts it to a driver DTO, calls one or more driver functions, and converts the output to another set of UI DTOs. As a result, from the UI to the driver, every Jaxon DbAdmin feature processes well-defined and strongly-typed data structures, which significantly boosts reliability.</p><p>At the core of the query execution feature, a new QueryProcessor class is introduced, serving as the only interface for query execution. It takes a set of queries in a DTO as input, calls the driver functions, and returns the results as a set of DTOs. It also accepts options allowing callers to decide whether to log queries or compute execution duration. In such cases, the corresponding features are enabled in the classes where they are implemented.</p><p>Another notable change is the QueryStream class, which allows the database import feature to stream uploaded file lines instead of loading them all at once into memory.</p><h3>Oncoming features</h3><h4>AI assistant</h4><p>The AI assistant is on top of the next releases feature list. Two interaction modes are planned. The Ask mode where the AI assistant can suggest SQL queries without actually executing any of them, and the Agent mode where it can also execute queries.</p><p>The Jaxon DbAdmin drivers are able to return detailed data about the database tables and columns. Combined with the Query Processor unique features, there form a solid basis for the AI assistant implementation.</p><h4>Enhanced query builder</h4><p>Currently, the Query Builder builds select queries only for a single table. In the future releases, it will be able to query multiple tables with joins, and convert complex select queries from SQL code to its internal data structure.</p><h4>UI templates</h4><p>The application UI is built with the <a href="https://github.com/lagdo/ui-builder">UI Builder</a> library. Three Bootstrap 5 templates are currently available, built from the open source <a href="https://github.com/startbootstrap/startbootstrap-sb-admin">SbAdmin</a>, <a href="https://coreui.io/">CoreUi 5</a> and <a href="https://plainadmin.com/">Plain Admin</a> dashboard templates.</p><p>Other CSS frameworks are planned to be supported by the <a href="https://github.com/lagdo/ui-builder">UI Builder</a> library, including TailwindCSS and Bulma. So in addition to Bootstrap 5, other templates based on these frameworks will be available in the future releases.</p><p>Integrating a new admin dashboard is easy, since it doesn’t require any changes to the application UI components code.</p><h4>Closing thoughts</h4><p>The latest releases of Jaxon DbAdmin introduce an extensive array of new features and improvements. On top of the existing database driver packages, a new engine for query generation and execution has been deployed, boosting reliability thanks to the use of DTOs. On the UI/UX front, the usability of every function has been significantly enhanced.</p><p>With its current roadmap, Jaxon DbAdmin will soon match the feature set of the market’s most advanced solutions, such as <a href="https://dbeaver.io/">DBeaver</a>, <a href="https://www.dbgate.io/">DbGate</a>, <a href="https://www.bytebase.com/">ByteBase</a>, and the more recent <a href="https://github.com/TabularisDB/tabularis">Tabularis</a> and <a href="https://github.com/t8y2/dbx">DBx</a>. It will even offer a superior alternative in certain areas, such as its database credentials management and native support for multiple secret managers. While alternative tools often restrict advanced features to paid plans, Jaxon DbAdmin offers all its functionalities completely for free.</p><p>Unlike these desktop-centric alternatives, Jaxon DbAdmin is a pure web application written in PHP, like <a href="https://adminer.org/">Adminer</a> and <a href="https://www.phpmyadmin.net/">PhpMyAdmin</a>. It therefore combines the security and centralized advantages of a server-side web application with the usability of a desktop client.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd6aebd25e46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A real world case of recursion done right in PHP]]></title>
            <link>https://blog.stackademic.com/a-real-world-case-of-recursion-done-right-in-php-c2f95840b8ae?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2f95840b8ae</guid>
            <category><![CDATA[ui-component]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 11:41:01 GMT</pubDate>
            <atom:updated>2026-06-13T17:01:06.770Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HGwzgcFMSLv4rArdTyJJIg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/fr/@unclearvision?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Yassine Ait Tahit</a> on <a href="https://unsplash.com/fr/photos/un-objet-noir-et-blanc-vole-dans-les-airs-yCJRGTi3MkQ?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Nick Cosentino <a href="http://twitter.com/DevLeaderCa">@DevLeaderCa</a> posted this message about recursion on X, ex Twitter, in October 2025, which received over 470 replies.</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/i/status/1984123215170421060&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ba41e7481168b5d618378953d68829d/href">https://medium.com/media/1ba41e7481168b5d618378953d68829d/href</a></iframe><p>I quote an excerpt: <em>I’ve found that converting over to an iterative loop based approach is almost always more readable and easier to debug. </em>He explains that in over 20 years of programming, he has never used recursion, thus questioning its usefulness.</p><p>In this article, I show a real case where I used recursion, and where I think that it is much simpler than its iterative counterpart.</p><p>But before going any further, let see what makes a recursive algorithm powerful.</p><h3>The Fibonacci sequence</h3><p>To understand the value of recursion, let’s look at the implementations with and without recursion of an algorithm very often used to illustrate it: the Fibonacci sequence.</p><p>Here’s the recursive algorithm.</p><pre>if n = 0 or n = 1 then<br>    fib(n) = 1<br>else<br>    fib(n) = fib(n − 1) + fib(n − 2)<br>endif</pre><p>And here’s the iterative one.</p><pre>if n = 0 or n = 1 then<br>    fib(n) = 1<br>else<br>    a = 1<br>    b = 1<br>    for i in 2 .. n do<br>        c = a + b<br>        a = b<br>        b = c<br>    endfor<br>    fib(n) = c<br>endif</pre><p>This simple example demonstrates the advantages of recursion: no loops and no intermediate variables.</p><p>This also gives us an indication of when recursion is advantageous, namely when the function can be defined with a simple expression depending on itself. This might not be the case for example when the data being processed is a graph instead of a tree.</p><h3>Our problem</h3><p>The library we’ll be talking about is the <a href="https://github.com/lagdo/ui-builder">PHP UI Builder</a>. It builds application UIs using components, as defined by CSS frameworks. It provides a common API which defines the components, and from which specialized libraries can generate HTML code for a given CSS framework, like Bootstrap, Bulma or Tailwind CSS.</p><h4>The UI components</h4><p>With its hierarchical component structure, a UI is particularly well-suited to a recursive algorithm. A component has properties, but can also contain components that themselves have some properties and can contain other components, and so on.</p><h4>The virtual components</h4><p>When building a UI from data, the result can sometimes vary depending on their values. Some components will only be created under certain conditions, others are multiplied according to the entries in a list or loop, and others may be an aggregate of individually defined components.</p><p>To represent these cases, our library introduces the concept of virtual components. These are components that take a set of data as input and produce as output a set of zero or more components, which may or may not be virtual.</p><p>There are 4 of them:</p><ul><li><strong>When</strong>: takes a condition as input and generates a component if it is met.</li><li><strong>Each</strong>: takes an array of data as input and generates a component for each element.</li><li><strong>Pick</strong>: takes a list of conditions as input and generates a different component depending on the first one that is true.</li><li><strong>List</strong>: aggregates any set of components into one.</li></ul><p>A UI will ultimately consist of a tree structure of components, each of which can be virtual or real. A real component can have several children, each of which can be virtual or real, and a virtual component generates a list of components, each of which can be virtual or real.</p><p>Here’s an example of a function using the UI library.</p><pre>/**<br> * @param array $collations<br> *<br> * @return string<br> */<br>public function addDbForm(array $collations): string<br>{<br>    return $this-&gt;ui-&gt;build(<br>        $this-&gt;ui-&gt;form(<br>            $this-&gt;ui-&gt;row(<br>                $this-&gt;ui-&gt;col(<br>                    $this-&gt;ui-&gt;label($this-&gt;ui-&gt;text(&#39;Name&#39;))<br>                        -&gt;setFor(&#39;name&#39;)<br>                )-&gt;width(3),<br>                $this-&gt;ui-&gt;col(<br>                    $this-&gt;ui-&gt;input()<br>                        -&gt;setType(&#39;text&#39;)<br>                        -&gt;setName(&#39;name&#39;)<br>                )-&gt;width(6)<br>            ),<br>            $this-&gt;ui-&gt;when(count($collations) === 0, fn() =&gt;<br>                $this-&gt;ui-&gt;input()<br>                    -&gt;setType(&#39;hidden&#39;)<br>                    -&gt;setName(&#39;collation&#39;)<br>                    -&gt;setValue(&#39;&#39;)),<br>            $this-&gt;ui-&gt;when(count($collations) &gt; 0, fn() =&gt;<br>                $this-&gt;ui-&gt;row(<br>                    $this-&gt;ui-&gt;col(<br>                        $this-&gt;ui-&gt;label($this-&gt;ui-&gt;text(&#39;Collation&#39;))<br>                            -&gt;setFor(&#39;collation&#39;)<br>                    )-&gt;width(3),<br>                    $this-&gt;ui-&gt;col(<br>                        $this-&gt;ui-&gt;select(<br>                            $this-&gt;ui-&gt;option(&#39;(collation)&#39;)<br>                                -&gt;setValue(&#39;&#39;)<br>                                -&gt;selected(true),<br>                            $this-&gt;ui-&gt;each($collations, fn($_collations, $group) =&gt;<br>                                $this-&gt;ui-&gt;pick(<br>                                    $this-&gt;ui-&gt;when($group === &#39;&#39;, fn() =&gt;<br>                                        $this-&gt;ui-&gt;each($_collations, fn($collation) =&gt;<br>                                            $this-&gt;ui-&gt;option($collation)<br>                                        )<br>                                    ),<br>                                    $this-&gt;ui-&gt;when(true, fn() =&gt;<br>                                        $this-&gt;ui-&gt;optgroup(<br>                                            $this-&gt;ui-&gt;each($_collations, fn($collation) =&gt;<br>                                                $this-&gt;ui-&gt;option($collation)<br>                                            )<br>                                        )-&gt;setLabel($group)<br>                                    )<br>                                )<br>                            )<br>                        )-&gt;setName(&#39;collation&#39;)<br>                    )-&gt;width(6)<br>                )<br>            )<br>        )<br>    );<br>}</pre><h4>The processing algorithm</h4><p>To generate a UI from a component tree, we will use the following algorithm:</p><pre>function build(c)<br>    children = []<br>    expand(c, children)<br><br>    c.elements = []<br>    for child in children<br>        if child is a component then<br>            build(child)<br>            append child.elements to c.elements<br>        else<br>            append child to c.elements<br>        endif<br>    endfor<br>endfunction</pre><pre>function expand(c, children)<br>    if c is virtual then<br>        for child in c.children<br>            expand(child, children)<br>        endfor<br>    else<br>        append c to children<br>    endif<br>endfunction</pre><p>What we have here is actually a combination of two recursive functions.</p><p>The expand() function returns the list of real components generated by a virtual component. It will therefore iterate recursively over all its children as long as virtual components are present.</p><p>The build() function, which is the entry point for the process, first calls the expand() function. Its list of children then consists only of real components, on which it executes recursively.</p><blockquote>[Edit on 2026–06–13]: The feature is moved to a new package at <a href="https://github.com/lagdo/ui-builder-html">https://github.com/lagdo/ui-builder-html</a>. It’s a standalone UI Builder which generates raw HTML code.</blockquote><p>The final result is here: <a href="https://github.com/lagdo/ui-builder-html/blob/main/src/Builder/Scope.php">https://github.com/lagdo/ui-builder-html/blob/main/src/Builder/Scope.php</a>. In their PHP implementation, the recursive expand() function contains 15 lines of code, and the build() function contains 40.</p><p>Two extremely simple functions, which form the basis that allows the implementation in a single library of both the templating functionalities of libraries such as Twig or Blade, and the HTML code generation of libraries such as <a href="https://spatie.be/docs/laravel-html/v3/general-usage/html-builder">Spatie’s HTML Builder</a> or <a href="https://symfony.com/doc/current/forms.html">Symfony’s Forms component</a> (the rendering part).</p><p>The UI library is used to build the <a href="https://github.com/lagdo/jaxon-dbadmin/tree/main">Jaxon DbAdmin UI</a>, demonstrating that it allows the construction of complex UIs, calling classes and their methods instead of writing HTML templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBPISSunyav1sqRa4J_ggA.png" /></figure><h3>The limitations of recursion</h3><p>Nick Cosentino’s message rightly points out two drawbacks of recursion, which we will briefly discuss here.</p><h4>Debugging</h4><p>First, it’s absolutely true that recursion is difficult to debug, particularly because mentally unraveling the instructions executed by a recursive algorithm is very complex. However, at the same time, the simplicity of recursive algorithms leaves little chance for a bug to occur.</p><p>Therefore, before choosing recursion, it’s important to ensure that the algorithm being implemented can be expressed very simply in a recursive manner. This is indeed the case for the Fibonacci sequence and our library.</p><h4>Memory usage</h4><p>Implementing a recursive algorithm can consume a significant amount of memory, depending on the level of nesting of the calls.</p><p>For our UI library, the level of nesting of an application’s UI components will always be very limited, and even more if it is built one part at a time, each in a separate recursive function call.</p><p>Moreover, PHP imposes a limit on the number of nested calls within a recursive function, and the consequence of an overflow will be to fail a single call, not to crash the entire server.</p><h3>The closing word</h3><p>To answer Nick Cosentino’s initial question, of course it is possible to create all sorts of complex software without using recursion.</p><p>However, this doesn’t mean it can always be replaced by an iterative version, but rather that cases where one can fully leverage all its advantages are not very common.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2f95840b8ae" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/a-real-world-case-of-recursion-done-right-in-php-c2f95840b8ae">A real world case of recursion done right in PHP</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure the Jaxon DbAdmin database credentials with Infisical]]></title>
            <link>https://medium.com/@thierry.feuzeu/secure-the-jaxon-dbadmin-database-credentials-with-infisical-995979891bad?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/995979891bad</guid>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 13:52:40 GMT</pubDate>
            <atom:updated>2026-10-11T00:34:46.552Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gT3JgnmrJ0YLY3hDSXzCsA.png" /></figure><p>This tutorial covers the use of the <a href="https://infisical.com/">Infisical</a> server with the <a href="https://github.com/lagdo/dbadmin-app">Jaxon DbAdmin</a> database management tool to store the credentials of the managed databases in a secure location. Jaxon DbAdmin is presented in <a href="https://medium.com/@thierry.feuzeu/what-if-we-improve-the-way-developers-are-given-access-to-databases-64cd7e2bef56">this previous post</a>.</p><blockquote>If you are not a Medium member, you can read the full article <a href="https://www.jaxon-php.org/blog/2026/01/secure-the-jaxon-dbadmin-database-credentials-with-infisical.html">here</a>.</blockquote><p>The first part covers the installation and configuration of the Jaxon DbAdmin application, while the second part covers the installation and setup of the Infisical server, and how it is used to secure the Jaxon DbAdmin application.</p><blockquote><strong>Note:<br></strong>While many of its feature are ready for use, Jaxon DbAdmin is still a work in progress, and is not yet ready for production.</blockquote><h4><strong>What is Infisical</strong></h4><p>According to its website, <a href="https://infisical.com/">Infisical</a> is a all-in-one platform to securely manage application secrets, certificates, SSH keys, and configurations across teams and infrastructures.</p><p>The feature we’ll be using here is <a href="https://infisical.com/docs/documentation/platform/secrets-mgmt/overview">Secrets Management</a>, which allow to centralize application secrets across environments and workloads, enforce identity-based access, auditing, and secure delivery at runtime.</p><h4><strong>Why use Infisical with Jaxon DbAdmin</strong></h4><p>By default, Jaxon DbAdmin stores all the database credentials on the server it is installed on. While this already brings a higher level of security compared to spreading the database credentials across the developer teams, the security can be further improved by storing the credentials in a secure location.</p><p>When managing multiple database servers or multiple Jaxon DbAdmin instances, fetching the database credentials from the Infisical server instead of providing them all when deploying the application, will make the deployment much more simple. Moreover, the Jaxon DbAdmin application can benefit from the many advanced credentials management features provided by Infisical, like password rotation, and synchronisation with the servers.</p><h4><strong>Install and populate the databases</strong></h4><p>In this tutorial, we’ll use Docker Compose to install the applications. Let’s start by creating the databases we are going to manage.</p><p>The Docker Compose file at <a href="https://github.com/lagdo/dbadmin-mono/tree/main/docker/compose-dbserver">https://github.com/lagdo/dbadmin-mono/tree/main/docker/compose-dbserver</a> will start four database servers: PostgreSQL 14, PostgreSQL 17, MariaDb 10 and MySQL 8.</p><p>The seed container provides scripts to populate the databases with datasets freely available online. Make sure to copy the <a href="https://github.com/lagdo/dbadmin-mono/tree/main/docker/seed">https://github.com/lagdo/dbadmin-mono/tree/main/docker/seed</a> and <a href="https://github.com/lagdo/dbadmin-mono/tree/main/jaxon-dbadmin/migrations">https://github.com/lagdo/dbadmin-mono/tree/main/jaxon-dbadmin/migrations</a> directories locally and update the volumes in the docker-compose.yml file accordingly.</p><p>Create and start the containers.</p><pre>docker compose up -d</pre><p>Now enter the seed container, and run the scripts in the /home/dbadmin/scripts directory to populate the PostgreSQL, MariaDB and MySQL databases.</p><p>The /home/dbadmin/scripts/pgsql/auditdb.sh script migrates the PostgreSQL 17 server for the Jaxon DbAdmin audit logs feature.</p><h4><strong>Install the Jaxon DbAdmin application</strong></h4><p>The Jaxon DbAdmin application is available as a Docker image at <a href="https://hub.docker.com/r/lagdo/jaxon-dbadmin">https://hub.docker.com/r/lagdo/jaxon-dbadmin</a>.</p><p>Before installing the application, we need some config files.</p><p>The config/dbadmin.json file lists the managed database servers, and defines the access per user or role.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a9995e8265b4af18e72040af4056abe/href">https://medium.com/media/9a9995e8265b4af18e72040af4056abe/href</a></iframe><p>In the config/dbadmin.php file, the audit logs are enabled and a database is defined for their storage. The audit database is PostgreSQL 17, which was migrated with the /home/dbadmin/scripts/pgsql/auditdb.sh script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82969fc472565506a0c34a6b0baaddb2/href">https://medium.com/media/82969fc472565506a0c34a6b0baaddb2/href</a></iframe><blockquote><strong>Note:</strong> <br>The environment variables are specified in a custom format. The env() function is not called directly.</blockquote><p>With this setup, the access to the database servers and the audit logs page is granted only to the user with email admin@company.com.</p><p>We now define the database addresses, port numbers and credentials as environment variables in the .env.dbadmin file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3f58745c1115debf628dd3693ce894e/href">https://medium.com/media/d3f58745c1115debf628dd3693ce894e/href</a></iframe><p>The Jaxon DbAdmin application can now be started with the following docker-compose.yml file. Make sure the config files are stored in the paths specified in this file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab49d97152a7831a1f5e826942017a95/href">https://medium.com/media/ab49d97152a7831a1f5e826942017a95/href</a></iframe><p>Since the database containers have exposed their port numbers, the jaxon-dbadmin container connects to them using the host address, as defined in the extra_hosts section.</p><p>The last install step is to create a user in the application. Enter the jaxon-dbadmin container, and run the following command, which will prompt for the user password.</p><pre>cd /var/www<br>php artisan user:create --name Admin --email admin@company.com</pre><blockquote><strong>Note:<br></strong>This command is a <a href="https://laravel.com/docs/12.x/artisan">Laravel Artisan console command</a>.</blockquote><p>Now, the Jaxon DbAdmin application is up and running, and the user can log in using the credentials provided in the above command, and browse the managed databases in multiple tabs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYr-2GV1ty2UCoftMeoohA.png" /><figcaption>Query a database table in Jaxon DbAdmin</figcaption></figure><h4><strong>Install and setup the Infisical server</strong></h4><p>At this point, the Jaxon DbAdmin application uses the credentials stored in the .env.dbadmin file to connect to the database servers. We are now going to migrate those credentials to a local instance of the <a href="https://infisical.com/">Infisical</a> running with Docker.</p><p>The Docker Compose file to run the Infisical server is here: <a href="https://github.com/lagdo/dbadmin-mono/tree/main/docker/compose-secret">https://github.com/lagdo/dbadmin-mono/tree/main/docker/compose-secret</a>. It is the same as <a href="https://github.com/Infisical/infisical/blob/main/docker-compose.prod.yml">this one</a>, with some slight changes.</p><p>After running the docker compose up -d command, the application can be browsed at http://localhost:7095. The user is now able to create a first admin user account and connect into the dashboard.</p><p>Create a project of type <em>Secrets Management</em> for the Jaxon DbAdmin credentials, and copy its id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LF7If3Yc9Cq7ioD7FCCC6A.png" /></figure><p>Create a machine identity for the DbAdmin application server, and add that new identity to the Jaxon DbAdmin project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYJc01_G8cHIeV0S8Nb91g.png" /></figure><p>Add a secret in the <em>Universal Auth</em> window, and copy the client id and client secret id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_UAgonXSF4XsSF5qFdMJ1g.png" /></figure><p>The last step here is to create the Jaxon DbAdmin secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NODGVGKc9DeI7vICseEmPA.png" /></figure><p>For each database server, there is a secret for the username and another one for the password. To keep things simple, each secret name has the same value as the corresponding option name in the Jaxon DbAdmin config, with users. as prefix.</p><h4><strong>Setup the Jaxon DbAdmin for Infisical</strong></h4><blockquote><strong>Edit 2026/02/10</strong>: The 0.9.0 release of Jaxon DbAdmin now includes by default a config reader for Infisical. It is no more required to add and register the InfisicalConfigReader class in the Jaxon container as described above. Read the <em>Config readers</em> section in the <a href="https://github.com/lagdo/dbadmin-app">documentation</a> for more information.</blockquote><p>We are now going to setup the Jaxon DbAdmin application to fetch the database credentials from the Infisical server.</p><p>First update the .env.dbadmin file with the Infisical server URL and ids, and delete the database credentials.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b767549337670e45251acf1b8a60372/href">https://medium.com/media/5b767549337670e45251acf1b8a60372/href</a></iframe><p>Jaxon DbAdmin uses a configurable <em>config reader</em> class to read database credentials. In order to be able to read those credentials from the Infisical server, we’ll need to provide a custom <em>config reader</em> class.</p><p>A <a href="https://github.com/lagdo/jaxon-dbadmin/blob/main/src/Config/ConfigReader.php">default class</a> is provided, which we are going to extend to implement our custom config reading feature.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54810f351cffe4281303c7219260fc44/href">https://medium.com/media/54810f351cffe4281303c7219260fc44/href</a></iframe><p>The getUsername() and getPassword() functions are overridden, and now get their values from the Infisical server.</p><blockquote><strong>Note:<br></strong>The $secretKey value needs to be set according to how the secret are stored in the Infisical project. The AuthInterface object can also allow to return a different key depending on the user email or role.</blockquote><p>This file will be located at app/Infisical/InfisicalConfigReader.php, and Jaxon DdAdmin needs to be configured to use it to read config. So the config/jaxon.php file is edited with the following changes: the App\Infisical\InfisicalConfigReader class is defined as the <em>config reader</em>, and a new entry is added in the Jaxon DI container.</p><pre>    &#39;packages&#39; =&gt; [<br>        Lagdo\DbAdmin\Db\DbAdminPackage::class =&gt; [<br>            // Config reader definition<br>            &#39;config&#39; =&gt; [<br>                &#39;reader&#39; =&gt; InfisicalConfigReader::class,<br>            ],<br>        ],<br>    ],<br>    &#39;container&#39; =&gt; [<br>        &#39;set&#39; =&gt; [<br>            // Config reader DI<br>            InfisicalConfigReader::class =&gt; function(Container $di) {<br>                $auth = $di-&gt;g(AuthInterface::class);<br><br>                $infisicalSdk = new InfisicalSDK(env(&#39;INFISICAL_SERVER_URL&#39;));<br>                $clientId = env(&#39;INFISICAL_MACHINE_CLIENT_ID&#39;);<br>                $clientSecret = env(&#39;INFISICAL_MACHINE_CLIENT_SECRET&#39;);<br>                // Authenticate on the Infisical server.<br>                $infisicalSdk-&gt;auth()-&gt;universalAuth()-&gt;login($clientId, $clientSecret);<br>                // Create the Infisical secrets service.<br>                $secrets = $infisicalSdk-&gt;secrets();<br>                $projectId = env(&#39;INFISICAL_PROJECT_ID&#39;);<br>                return new InfisicalConfigReader($auth, $secrets, $projectId, &#39;dev&#39;);<br>            },<br>        ],<br>    ],</pre><blockquote><strong>Note:<br></strong>The App\Infisical\InfisicalConfigReader class can be defined in the <a href="https://laravel.com/docs/12.x/container">Laravel service container</a> instead.</blockquote><p>Here’s the modified config/jaxon.php file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6669068da9ef20bfaeedede6e8363258/href">https://medium.com/media/6669068da9ef20bfaeedede6e8363258/href</a></iframe><p>The databases credentials can now be removed from the config/dbadmin.json config file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/656fdcbb88cecce5ed89aa3b7ab87545/href">https://medium.com/media/656fdcbb88cecce5ed89aa3b7ab87545/href</a></iframe><p>This Dockerfile installs the <a href="https://infisical.com/docs/sdks/languages/php">Infisical PHP SDK</a> in the Jaxon DbAdmin application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31d529912d89bb00b2f3384bf24a6827/href">https://medium.com/media/31d529912d89bb00b2f3384bf24a6827/href</a></iframe><p>The new docker-compose.yml will now setup the Jaxon DbAdmin application to read the managed databases credentials from the local Infisical server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24effc467426708ccbe75886f276cb3c/href">https://medium.com/media/24effc467426708ccbe75886f276cb3c/href</a></iframe><p>Jaxon DbAdmin now runs exactly as before, but without any database username or password stored locally.</p><h4><strong>Securing the Jaxon DbAdmin application with Infisical</strong></h4><p>While the <a href="https://infisical.com/docs/sdks/languages/php">Infisical PHP SDK</a> documentation recommends to set the <a href="https://infisical.com/docs/documentation/platform/identities/overview">machine identity tokens</a> as environment variables, as we did in this tutorial, the Infisical service can also secure the entire application.</p><p>A howto for the Laravel framework is provided: <a href="https://infisical.com/docs/integrations/frameworks/laravel">https://infisical.com/docs/integrations/frameworks/laravel</a>. With this feature, the Infisical cli injects the environment variables and secrets into the Laravel application, Jaxon DbAdmin in our case.</p><p>The question that might arise here is why use the Jaxon DbAdmin custom <em>config reader</em> instead of the Infisical cli. The main difference is that the Infisical cli injects all the secrets once when the application server (not the Laravel application itself) starts, while the <em>config reader</em> fetches the secrets it needs from the Infisical server on each request, and is then able to ask for or receive a different secret depending on the current application state, or the changes on the Infisical server.</p><p>So the user might choose the technique that best fits its requirements, and even use both of them simultaneously.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=995979891bad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What if we improve the way developers are given access to databases]]></title>
            <link>https://medium.com/@thierry.feuzeu/what-if-we-improve-the-way-developers-are-given-access-to-databases-64cd7e2bef56?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/64cd7e2bef56</guid>
            <category><![CDATA[user-management]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-applications]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Wed, 27 Aug 2025 17:46:26 GMT</pubDate>
            <atom:updated>2025-08-27T17:46:26.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Rvm-54fVLdwQu8kfczCqw.png" /></figure><p>Developers often need direct access to the databases used by the applications they work on, in virtually every environment of a project: development, testing, pre-production, and sometimes even in production.</p><p>To do this, they use software such as <a href="https://www.adminer.org/">Adminer</a>, <a href="https://www.phpmyadmin.net/">PhpMyAdmin</a>, <a href="https://dbeaver.io/">DBeaver</a>, and many others, which share a common feature: they authenticate their users with database access parameters. This pushes teams within companies to share database access credentials with developers, which, in the best-case scenario, is done with a <em>password manager</em> software.</p><p>This sharing of database credentials can pose several risks. Accidental leaks of sensitive information, if a developer inadvertently shares this data with third parties. Reuse of credentials in inappropriate environments. Uncontrolled and untraceable access, due to the sharing of this information with multiple developers. Access by unauthorized individuals, when developers leave the company.</p><p>Enforcing good security practices under these conditions will be difficult.</p><h4><strong>Jaxon DbAdmin</strong></h4><p><strong>Jaxon DbAdmin</strong> is a web-based database management application that takes a different approach to user authentication and database connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OykavRoBuoogzfFlt0FRNw.png" /><figcaption>The Jaxon DbAdmin query editor</figcaption></figure><p>The application clearly separates the authentication of its users and the connections to databases. The parameters of the later are stored only in its configuration file on the server.</p><p>When a user logs in, <strong>Jaxon DbAdmin</strong> reads the list of databases he has access to from its configuration and presents it to him. And when the user performs an action on a database, <strong>Jaxon DbAdmin</strong> reads the corresponding database credentials from its configuration, executes the action, and returns the result. This allows the user to access the database contents without having access to the database credentials.</p><p>It’s worth noting that this database access technique isn’t exactly new. On the one hand, applications that use databases already store database credentials this way, and on the other, there are already database management applications that authenticate their users elsewhere than in the database. <strong>Jaxon DbAdmin</strong> combines these two approaches to make it its default mode.</p><p><strong>Jaxon DbAdmin</strong> is an open source software distributed under the BSD-3-Clause license: <a href="https://github.com/lagdo/dbadmin-app">https://github.com/lagdo/dbadmin-app</a>. A Docker image is also provided: <a href="https://hub.docker.com/r/lagdo/jaxon-dbadmin">https://hub.docker.com/r/lagdo/jaxon-dbadmin</a>.</p><blockquote><strong>Jaxon DbAdmin</strong> is still being actively developed, and some features are not yet available.</blockquote><h4><strong>The advantages</strong></h4><p>Storing database credentials on the server only enhances security. Developers cannot copy, transfer, or expose credentials, even by mistake. Each request can be linked to a specific user or role, making it easy to audit who did what, and when. Login credentials are no longer scattered across development workstations, in configuration files, emails, or other communication tools. They can even be secured in a vault.</p><p>Connection configuration is now managed at the platform or infrastructure level, not in the application code. This makes it easier to manage environments (dev, staging, production). Since users don’t have access to the database credentials, they can be changed regularly without disrupting applications or developers. Similarly, if the credentials are compromised, the administrator won’t have to change them on developer workstations. This is done in a single location, transparently for applications and users.</p><p>There will also be better permission management based on the principle of least privilege: each user only has access to what he needs, regardless of the database credentials actually used. If a developer leaves, his access to the application can simply be revoked, without having to change the database credentials and impact all other applications and users.</p><p>Finally, many security standards require strict data access management. Not sharing database credentials makes it easier to comply with these requirements.</p><h4><strong>The challenges</strong></h4><p>Despite the above advantages, the use of existing tools that offer separate authentication is not common enough because they face several challenges.</p><p>Setting up and using a secrets management system (vault) or an API Gateway with the necessary permissions is complex. For a small team or on certain projects, this represents a significant overhead in terms of time, skills, and budget. On the other hand, tools such as <a href="https://dbeaver.io/">DBeaver</a> (Community) and <a href="https://www.adminer.org/">Adminer</a> are free and open-source.</p><p>Certain complex tasks (analyzing indexes, optimizing queries, performing large-scale exports/imports) are much simpler with a graphical tool than with a command line or REST API. The same is true for analyzing the structure of a complex database with many tables. The user-friendliness of the graphical interface of tools like <a href="https://dbeaver.io/">DBeaver</a> or <a href="https://www.adminer.org/">Adminer</a> is a definite advantage.</p><p>Experienced developers sometimes like to have direct control over the database. They appreciate the speed of an <em>ad hoc</em> SQL query to explore a database schema, understand relationships between tables, or test complex logic before writing it in code. For occasional manipulations, connecting with a graphical tool seems faster.</p><p>It is difficult to replicate an environment where direct access to the database is prohibited on a development workstation. Developers then need a local database to code on, and in this case, access security isn’t a priority. <a href="https://www.adminer.org/">Adminer</a> or <a href="https://dbeaver.io/">DBeaver</a> are ideal for this, and the temptation is great to use the same tool for all environments.</p><p>Many developers have always worked with direct database access. In many companies, sharing database access credentials is a historical and culturally entrenched practice. Changing this requires shifting processes and mindsets. Furthermore, not all developers are aware of the risks or alternative best practices.</p><h4><strong>In conclusion</strong></h4><p><strong>Jaxon DbAdmin</strong> is a web-based database management application that separates user authentication and database connections, meaning that database credentials are not shared with users accessing them. Its configuration allows the administrator to define credentials for each user or group of users.</p><p>It will therefore improve the security of access to databases, while maintaining the user-friendliness and simplicity of a graphical interface.</p><p>Its code comes <a href="https://github.com/vrana/adminer/">from Adminer</a>, which has been refactored and modernized. Although its UI has also been modernized, it offers similar functions as <a href="https://www.adminer.org/">Adminer</a>.</p><p>However, <strong>Jaxon DbAdmin</strong> is still being actively developed, and some features are not yet available.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64cd7e2bef56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Si on améliorait l’accès des développeurs aux bases de données]]></title>
            <link>https://medium.com/@thierry.feuzeu/si-on-am%C3%A9liorait-lacc%C3%A8s-des-d%C3%A9veloppeurs-aux-bases-de-donn%C3%A9es-a8eebb15e5a1?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8eebb15e5a1</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-applications]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[database-administration]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 22:34:00 GMT</pubDate>
            <atom:updated>2025-08-26T23:06:38.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Rvm-54fVLdwQu8kfczCqw.png" /></figure><p>Les développeurs ont souvent besoin d’un accès direct aux bases de données utilisées par les applications sur lesquelles ils travaillent, ceci dans pratiquement tous les environnements d’un projet: développement, test, pré-production, et parfois même en production.</p><blockquote>Si vous n’êtes pas membre Medium, cet article est en <a href="https://www.jaxon-php.org/blog/2025/08/si-on-ameliorait-l-acces-des-developpeurs-aux-bases-de-donnees.html">libre accès ici</a>.</blockquote><p>Ils utilisent pour cela des logiciels tels que <a href="https://www.adminer.org/">Adminer</a>, <a href="https://www.phpmyadmin.net/">PhpMyAdmin</a>, <a href="https://dbeaver.io/">DBeaver</a>, et bien d’autres, qui ont la particularité d’authentifier leurs utilisateurs avec les paramètres d’accès aux bases de données.</p><p>Ceci pousse les administrateurs de bases de données dans les entreprises à partager avec les développeurs les identifiants et les mots de passe, ce qui dans le meilleur des cas se fait des logiciels de type <em>password manager</em>.</p><p>Ce partage des informations de connexion peut poser un certain nombre de risques.</p><p>Des fuite accidentelles d’informations sensibles, si un développeur partage par mégarde ces données avec des tiers. La réutilisation des identifiants dans des environnements inappropriés. Des accès non contrôlés et non tracés, à cause du partage de ces informations entre plusieurs développeurs. Des accès à des personnes non autorisées, lorsque des développeurs quittent l’entreprise.</p><p>Il va être difficile de faire respecter les bonnes pratiques de sécurité dans ces conditions.</p><h4><strong>Jaxon DbAdmin</strong></h4><p><a href="https://github.com/lagdo/dbadmin-app"><strong>Jaxon DbAdmin</strong></a> est une application web de gestion de bases de données qui apporte une approche différente à l’authentification des utilisateurs et la connexion aux bases de données.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OykavRoBuoogzfFlt0FRNw.png" /></figure><p>L’application gère séparément l’authentification de ses utilisateurs et les connexions aux bases de données, dont les paramètres sont stockés uniquement dans son fichier de configuration sur le serveur.</p><p>Lorsqu’un utilisateur se connecte, <strong>Jaxon DbAdmin</strong> lit dans sa configuration la liste des bases de données auxquelles il a accès et la lui présente. Et lorsque l’utilisateur effectue une action sur une base de données, <strong>Jaxon DbAdmin</strong> lit dans sa configuration les identifiants de connexion correspondants, exécute l’action et lui renvoie le résultat. Ainsi, l’utilisateur accède aux bases de données sans avoir accès aux identifiants de connexion.</p><p>Notons que cette technique d’accès aux bases de données n’est pas vraiment nouvelle. D’une part, les applications qui utilisent des bases de données stockent déjà de cette façon les identifiants de connexion, et d’autre part, il existe déjà des applications de gestion de bases de données qui authentifient leurs utilisateurs ailleurs que sur les bases de données. <strong>Jaxon DbAdmin</strong> combine ces deux approches pour en faire son fonctionnement par défaut.</p><p><strong>Jaxon DbAdmin</strong> est un logiciel open source distribué sous licence BSD 3-Clause: <a href="https://github.com/lagdo/dbadmin-app.">https://github.com/lagdo/dbadmin-app.</a><br>Une image Docker est également fournie: <a href="https://hub.docker.com/r/lagdo/jaxon-dbadmin.">https://hub.docker.com/r/lagdo/jaxon-dbadmin.</a></p><blockquote><strong>Jaxon DbAdmin</strong> est toujours activement développée, et certaines fonctions ne sont pas encore disponibles.</blockquote><h4><strong>Les avantages</strong></h4><p>Le stockage des identifiants de connexion sur un serveur renforce la sécurité. Les développeurs ne peuvent pas copier, transférer ou exposer les identifiants, même par erreur. Chaque requête peut être liée à un utilisateur ou à un rôle spécifique, ce qui permet d’auditer facilement qui a fait quoi, et quand. Les identifiants de connexion ne sont plus disséminés sur les postes de développement, dans des fichiers de configuration, dans des emails ou autres outils de communication. Ils peuvent même être sécurisés dans un coffre-fort (vault).</p><p>La configuration des connexions est désormais gérée au niveau de la plateforme ou de l’infrastructure, et non du code de l’application. Cela facilite la gestion des environnements (dev, staging, prod). Puisque les utilisateurs n’ont pas les identifiants, on peut les changer régulièrement sans perturber les applications ou les développeurs. De même, si les identifiants sont compromis, l’administrateur n’aura pas à les changer sur les postes des développeurs. Cela se fait à un seul endroit, de façon transparente pour les applications et les utilisateurs.</p><p>On aura également une meilleure gestion des autorisations selon le principe du moindre privilège : chaque utilisateur n’accède qu’à ce dont il a besoin, indépendamment des identifiants réellement utilisés. En cas de départ d’un développeur, il suffit de révoquer son accès à l’application, sans avoir à modifier le mot de passe de la base de données et à impacter toutes les autres applications et personnes.</p><p>Enfin, de nombreuses normes de sécurité exigent une gestion stricte des accès aux données. Ne pas partager les identifiants d’accès aux bases de données facilite le respect de ces exigences.</p><h4><strong>Les challenges</strong></h4><p>Malgré les avantages ci-dessus, l’utilisation des outils existants qui offrent une authentification séparée n’est pas assez courante car elle se heurte à plusieurs challenges.</p><p>Mettre en place et utiliser un système de gestion des secrets (Vault) ou une API Gateway avec les permissions nécessaires est complexe. Pour une petite équipe ou sur certains projets, cela représente une surcharge importante en termes de temps, de compétences et de budget. D’un autre côté, les outils tels que <a href="https://dbeaver.io/">DBeaver</a> (Community) et <a href="https://www.adminer.org/">Adminer</a> sont gratuits et open-source.</p><p>Certaines tâches complexes (analyser des indexes, optimiser des requêtes, faire des exports/imports massifs) sont beaucoup plus simples avec un outil graphique qu’avec une ligne de commande ou une API REST. Il en est de même de l’analyse de la structure d’une base de données complexe avec de nombreuses tables. La convivialité de l’interface graphique des outils comme <a href="https://dbeaver.io/">DBeaver</a> ou <a href="https://www.adminer.org/">Adminer</a> est un avantage certain.</p><p>Les développeurs expérimentés aiment parfois avoir la main directe sur la base. Ils apprécient la rapidité d’une requête SQL <em>ad hoc</em> pour explorer un schéma de base de données, comprendre les relations entre les tables, ou tester une logique complexe avant de l’écrire dans le code. Pour des manipulations ponctuelles, se connecter avec un outil graphique leur semble plus rapide.</p><p>Il est difficile de reproduire localement un environnement où l’accès direct à la base est interdit. Les développeurs ont alors besoin d’une base de données locale pour coder, et dans ce cas la sécurité des accès n’est pas une priorité. <a href="https://www.adminer.org/">Adminer</a> ou <a href="https://dbeaver.io/">DBeaver</a> conviennent très bien à cette situation, et la tentation est grande d’utiliser le même outil pour tous les environnements.</p><p>Beaucoup de développeurs ont toujours travaillé avec des accès directs à la base de données. Dans de nombreuses entreprises, partager les identifiants d’accès aux bases de données est une pratique historique et culturellement ancrée. Changer cela nécessite de modifier les processus et les mentalités. De plus, tous les développeurs ne sont pas conscients des risques ou des meilleures pratiques alternatives.</p><h4><strong>En conclusion</strong></h4><p><strong>Jaxon DbAdmin</strong> est une application web de gestion de bases de données qui sépare l’authentification des utilisateurs et les connexions aux bases de données, dont les identifiants ne sont donc pas partagés avec les utilisateurs qui y accèdent. Sa configuration permet de définir les identifiants correspondant à chaque utilisateur ou chaque groupe d’utilisateurs.</p><p>Il va donc permettre d’améliorer la sécurité des accès aux bases de données, tout en conservant la convivialité et la simplicité d’une interface graphique.</p><p>Son code provient de <a href="https://github.com/vrana/adminer/">celui d’Adminer</a>, qui a été refactorisé et modernisé. Bien que son UI ait également été modernisé, il offre des fonctions similaires à <a href="https://www.adminer.org/">Adminer</a>.</p><p>Cependant, <strong>Jaxon DbAdmin</strong> est toujours activement développé, et certaines fonctions ne sont pas encore disponibles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8eebb15e5a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Jaxon DbAdmin on Backpack]]></title>
            <link>https://medium.com/@thierry.feuzeu/install-jaxon-dbadmin-on-backpack-89c06b70edee?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/89c06b70edee</guid>
            <category><![CDATA[database-administration]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[adminer]]></category>
            <category><![CDATA[backpack]]></category>
            <category><![CDATA[jaxon]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 13:47:00 GMT</pubDate>
            <atom:updated>2025-07-23T18:50:01.418Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*eV3iaa1Ufujap8qJGOEYQg.png" /></figure><blockquote>If you are not a Medium member, you can read the full article <a href="https://www.jaxon-php.org/blog/2025/07/install-jaxon-dbadmin-on-backpack.html">here</a>.</blockquote><p>The two most popular PHP web applications for database administration are <a href="https://www.phpmyadmin.net/">phpMyAdmin</a> and <a href="https://www.adminer.org/">Adminer</a>. Both are standalone applications that need to be installed on a web server.</p><p>The <a href="https://www.jaxon-php.org/">Jaxon library</a> offers another choice, <a href="https://github.com/lagdo/jaxon-dbadmin">Jaxon DbAdmin</a>, which inserts a database administration tool into a page of an existing PHP web application.</p><blockquote>Jaxon DbAdmin is still a work in progress, and is not yet ready for production.</blockquote><h4><strong>What is Adminer</strong></h4><p><a href="https://adminer.org/">Adminer</a> (formerly phpMinAdmin) is a full-featured database management tool written in PHP. Unlike phpMyAdmin, it consist of a single file ready to deploy to the target server. Adminer is available for MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Elasticsearch, MongoDB and others via plugin.</p><h4><strong>What is Jaxon DbAdmin</strong></h4><p><em>Jaxon DbAdmin</em> results from the fork and redesign of the <a href="https://adminer.org/">Adminer</a> core features into several <a href="https://github.com/lagdo/dbadmin-mono">Composer packages</a>, and the integration of the <a href="https://www.jaxon-php.org/">Jaxon library</a>.</p><p>Unlike <em>Adminer</em> which is a standalone application, <em>Jaxon DbAdmin</em> is a <a href="https://www.jaxon-php.org/docs/v5x/extensions/packages.html">Jaxon package</a> which allows the user to insert the Adminer features into an existing PHP application. <em>Jaxon DbAdmin</em> is therefore available in a page of the application, whose content is updated with ajax requests generated by <a href="https://www.jaxon-php.org/">Jaxon</a>.</p><p>As a additional consequence, the authentication and security features are removed from the package, which will then rely on those provided by the application it is installed on.</p><h4><strong>What is Backpack</strong></h4><p><a href="https://backpackforlaravel.com/">Backpack</a> is a flexible admin panel for Laravel, that exists since 2016. Because it keeps things simple, it is widely regarded as being both easy to learn and easy to customize.</p><p>In addition to Laravel, it is built on the <a href="https://getbootstrap.com/">Bootstrap 5</a> CSS framework, which is supported by the <a href="https://github.com/lagdo/ui-builder-bootstrap5">UI library</a> used by Jaxon DbAdmin.</p><h4><strong>Install Laravel and Backpack</strong></h4><p>Althougth this article describes the installation of Jaxon DbAdmin on Backpack, the main steps are the same for the installation on others environments.</p><ul><li>Install the Jaxon packages,</li><li>Create the page that will display the Jaxon DbAdmin dashboard,</li><li>Add a route and a menu entry for this page,</li><li>Configure Jaxon and its packages, among which Jaxon DbAdmin.</li></ul><p>First, we will install Backpack on the version 12 of Laravel, <a href="https://backpackforlaravel.com/docs/6.x/installation">following its documentation</a>.</p><pre>composer create-project laravel/laravel backpack 12.x<br>cd backpack<br>composer require backpack/crud</pre><p>After we have defined the database access parameters in the <em>.env</em> file, we can take the final step of the installation and create an admin account.</p><pre>php artisan backpack:install</pre><p>This command will ask for information to create an admin account, and also to choose a theme. We have chosen <a href="https://github.com/laravel-backpack/theme-tabler/">Tabler</a>, a Bootstrap 5 template.</p><p>After the command has completed, we can login on Backpack, on the <em>/admin</em> path in the installed application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*pwNmMQ527Js5HNdP4rvnkg.png" /></figure><h4><strong>Install the Jaxon packages</strong></h4><p>In addition to the <em>lagdo/jaxon-dbadmin</em> package, we need to install the <em>jaxon-php/jaxon-laravel</em> package, for integration with <a href="https://laravel.com/">Laravel</a>, the framework Backpack is built with.</p><p>For the database drivers, we need to install the <em>lagdo/dbadmin-driver-mysql</em>, <em>lagdo/dbadmin-driver-pgsql</em> or <em>lagdo/dbadmin-driver-sqlite</em> packages, depending on the databases that will be managed.</p><p>Finally, we need to install packages for the UI. At the time this article is published, only the Bootstrap CSS framework is supported. We’ll install the <a href="https://github.com/lagdo/ui-builder-bootstrap">package for Bootstrap 5</a>.</p><blockquote>Some of the packages to be installed are still being actively developed. So we need to set the <em>minimum-stability</em> value to <em>dev</em> in the <em>composer.json</em> file, and install those packages from the <em>dev-main</em> branch.</blockquote><pre>composer require jaxon-php/jaxon-laravel jaxon-php/jaxon-dialogs jaxon-php/jaxon-upload<br>composer require lagdo/jaxon-dbadmin:dev-main lagdo/dbadmin-driver-mysql:dev-main \<br>    lagdo/dbadmin-driver-pgsql:dev-main lagdo/dbadmin-driver-sqlite:dev-main<br>composer require lagdo/ui-builder-bootstrap5:dev-main</pre><p>The <em>php artisan route:list | grep jaxon</em> command now prints the following line, showing that a route exists for Jaxon requests. Thanks to the Laravel package discovery feature.</p><pre>POST       jaxon ... (more dots) ... jaxon.ajax</pre><h4><strong>Create a page for Jaxon DbAdmin</strong></h4><p>We are now going to add a route and a view that will display the Jaxon DbAdmin page. The Backpack admin panel really makes those tasks very easy.</p><p>The <em>resources/views/admin/dbadmin.blade.php</em> view extends the <em>blank</em> template, and inserts the HTML, CSS and javascript codes of Jaxon DbAdmin in the page.</p><p>The <a href="https://fontawesome.com/">Font Awesome</a> icon set is also added, because it is used in the Jaxon DbAdmin UI.</p><pre>@extends(backpack_view(&#39;blank&#39;))<br><br>@push(&#39;after_styles&#39;)<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;//use.fontawesome.com/releases/v5.15.4/css/all.css&quot;&gt;<br><br>    @jxnCss<br>@endpush<br><br>@push(&#39;after_scripts&#39;)<br>    @jxnJs<br><br>    @jxnScript<br>@endpush<br><br>@section(&#39;content&#39;)<br>&lt;div style=&quot;margin:0 -10px; padding:5px; background-color:white; border-radius:5px;&quot;&gt;<br>    &lt;div style=&quot;margin-left:5px&quot;&gt;<br>        &lt;h2&gt;Jaxon DB Admin&lt;/h2&gt;<br>    &lt;/div&gt;<br>    &lt;div&gt;<br>        {!! jaxon()-&gt;package(Lagdo\DbAdmin\Package::class)-&gt;getHtml() !!}<br>    &lt;/div&gt;<br>&lt;/div&gt;<br>@endsection</pre><p>The route is added in the <em>routes/backpack/custom.php</em> file, where custom routes are defined.</p><pre>Route::group([<br>    &#39;prefix&#39; =&gt; config(&#39;backpack.base.route_prefix&#39;, &#39;admin&#39;),<br>    &#39;middleware&#39; =&gt; array_merge(<br>        (array) config(&#39;backpack.base.web_middleware&#39;, &#39;web&#39;),<br>        (array) config(&#39;backpack.base.middleware_key&#39;, &#39;admin&#39;)<br>    ),<br>    &#39;namespace&#39; =&gt; &#39;App\Http\Controllers\Admin&#39;,<br>], function () { // custom admin routes<br>    // Jaxon DbAdmin route<br>    Route::get(&#39;dbadmin&#39;, fn() =&gt; view(&#39;admin.dbadmin&#39;))<br>        -&gt;middleware(&#39;jaxon.config&#39;)<br>        -&gt;name(&#39;dbadmin&#39;);<br>}); // this should be the absolute last line of this file</pre><p>The route displays the view, after having called the <em>jaxon.config</em> middleware to setup the Jaxon library.</p><p>Now we can create a menu entry for Jaxon DbAdmin, by adding the following content in the <em>resources/views/vendor/backpack/ui/inc/menu_items.blade.php</em> file.</p><pre>&lt;li class=&quot;nav-item&quot;&gt;<br>    &lt;a class=&quot;nav-link&quot; href=&quot;{{ backpack_url(https://medium.com/&#39;dbadmin&#39;) }}&quot;&gt;<br>        &lt;i class=&quot;la la-database nav-icon&quot;&gt;&lt;/i&gt; DB Admin<br>    &lt;/a&gt;<br>&lt;/li&gt;</pre><h4><strong>Jaxon configuration</strong></h4><p>The last step is to define the Jaxon library config in the <em>config\jaxon.php</em> file. This also includes the Jaxon DbAdmin package config, where the database servers to be managed are defined.</p><pre>return [<br>    &#39;app&#39; =&gt; [<br>        &#39;request&#39; =&gt; [<br>            &#39;route&#39; =&gt; &#39;jaxon.ajax&#39;, // The route name<br>            &#39;middlewares&#39; =&gt; [&#39;web&#39;, &#39;auth&#39;],<br>        ],<br>        &#39;directories&#39; =&gt; [],<br>        &#39;packages&#39; =&gt; [<br>            Lagdo\DbAdmin\Package::class =&gt; [<br>                // The database servers<br>                &#39;servers&#39; =&gt; [<br>                    &#39;db-postgresql&#39; =&gt; [ // A unique identifier for this server<br>                        &#39;driver&#39; =&gt; &#39;pgsql&#39;,<br>                        &#39;name&#39; =&gt; &#39;PostgreSQL 14&#39;,     // The name to be displayed in the dashboard UI.<br>                        &#39;host&#39; =&gt; &#39;db-postgresql&#39;,     // The database host name or address.<br>                        &#39;port&#39; =&gt; 5432,      // The database port. Optional.<br>                        &#39;username&#39; =&gt; &#39;********&#39;, // The database user credentials.<br>                        &#39;password&#39; =&gt; &#39;********&#39;, // The database user credentials.<br>                    ],<br>                    &#39;db-mariadb&#39; =&gt; [ // A unique identifier for this server<br>                        &#39;driver&#39; =&gt; &#39;mysql&#39;,<br>                        &#39;name&#39; =&gt; &#39;MariaDB 10&#39;,     // The name to be displayed in the dashboard UI.<br>                        &#39;host&#39; =&gt; &#39;db-mariadb&#39;,     // The database host name or address.<br>                        &#39;port&#39; =&gt; 3306,      // The database port. Optional.<br>                        &#39;username&#39; =&gt; &#39;********&#39;, // The database user credentials.<br>                        &#39;password&#39; =&gt; &#39;********&#39;, // The database user credentials.<br>                    ],<br>                    &#39;db-mysql&#39; =&gt; [ // A unique identifier for this server<br>                        &#39;driver&#39; =&gt; &#39;mysql&#39;,<br>                        &#39;name&#39; =&gt; &#39;MySQL 8&#39;,     // The name to be displayed in the dashboard UI.<br>                        &#39;host&#39; =&gt; &#39;db-mysql&#39;,     // The database host name or address.<br>                        &#39;port&#39; =&gt; 3306,      // The database port. Optional.<br>                        &#39;username&#39; =&gt; &#39;********&#39;, // The database user credentials.<br>                        &#39;password&#39; =&gt; &#39;********&#39;, // The database user credentials.<br>                    ],<br>                    &#39;sqlite-3&#39; =&gt; [ // A unique identifier for this server/var/www<br>                        &#39;driver&#39; =&gt; &#39;sqlite&#39;,<br>                        &#39;name&#39; =&gt; &#39;Sqlite 3&#39;,     // The name to be displayed in the dashboard UI.<br>                        &#39;directory&#39; =&gt; &#39;/var/lib/sqlite/3&#39;, // The directory containing the database files.<br>                    ],<br>                ],<br>            ],<br>        ],<br>        &#39;ui&#39; =&gt; [<br>            &#39;template&#39; =&gt; &#39;bootstrap5&#39;,<br>        ],<br>        &#39;dialogs&#39; =&gt; [<br>            &#39;default&#39; =&gt; [<br>                &#39;modal&#39; =&gt; &#39;bootbox&#39;,<br>                &#39;alert&#39; =&gt; &#39;toastr&#39;,<br>                &#39;confirm&#39; =&gt; &#39;noty&#39;,<br>            ],<br>        ],<br>    ],<br>    &#39;lib&#39; =&gt; [<br>        &#39;core&#39; =&gt; [<br>            &#39;language&#39; =&gt; &#39;en&#39;,<br>            &#39;encoding&#39; =&gt; &#39;UTF-8&#39;,<br>            &#39;prefix&#39; =&gt; [<br>                &#39;class&#39; =&gt; &#39;&#39;,<br>            ],<br>            &#39;request&#39; =&gt; [<br>                &#39;csrf_meta&#39; =&gt; &#39;csrf-token&#39;,<br>                &#39;uri&#39; =&gt; &#39;/jaxon&#39;, // The route url<br>            ],<br>            &#39;debug&#39; =&gt; [<br>                &#39;on&#39; =&gt; false,<br>                &#39;verbose&#39; =&gt; false,<br>            ],<br>            &#39;error&#39; =&gt; [<br>                &#39;handle&#39; =&gt; false,<br>            ],<br>        ],<br>        &#39;js&#39; =&gt; [<br>            &#39;lib&#39; =&gt; [<br>                // &#39;uri&#39; =&gt; &#39;&#39;,<br>            ],<br>            &#39;app&#39; =&gt; [<br>                // &#39;uri&#39; =&gt; &#39;&#39;,<br>                // &#39;dir&#39; =&gt; &#39;&#39;,<br>                // &#39;export&#39; =&gt; true,<br>                // &#39;minify&#39; =&gt; true,<br>            ],<br>        ],<br>    ],<br>];</pre><p>The <em>lib.core.request.csrf_meta</em> option adds <a href="https://laravel.com/docs/12.x/csrf">Laravel CSRF protection</a> on Jaxon requests. The <em>app.ui.template</em> defines the UI library to use, here <em>bootstrap5</em>. The <em>app.dialogs</em> section defines the libraries to use for <a href="https://www.jaxon-php.org/docs/v5x/ui-features/dialogs.html">dialogs</a>. The <em>servers</em> option in the <em>app.packages.Lagdo\DbAdmin\Package</em> section defines the list of servers to be managed. The Jaxon request route access is also protected with the Laravel <em>auth</em> middleware.</p><blockquote>The database credentials can be moved to the <em>.env</em> file.</blockquote><p>The installation of Jaxon DbAdmin on Backpack has now been completed. The above image shows how the page is displayed to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbYQrK5oDvhSH_01C_BQxA.png" /></figure><p>The user can for example browse the content of the Backpack database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6oDTEbE1_tXCgXIcw6vQNQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89c06b70edee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing the version 5 of the Jaxon library]]></title>
            <link>https://medium.com/@thierry.feuzeu/announcing-the-version-5-of-jaxon-library-22e551ea5f4a?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/22e551ea5f4a</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[jaxon]]></category>
            <category><![CDATA[ajax]]></category>
            <category><![CDATA[new-releases]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 13:01:42 GMT</pubDate>
            <atom:updated>2025-07-16T03:53:49.252Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enWng_hGsuwHWlGuR2BzAw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@benofthenorth?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ben Griffiths</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><blockquote>If you are not a Medium member, you can read the full article <a href="https://www.jaxon-php.org/blog/2025/07/announcing-jaxon-version-5.html">here</a>.</blockquote><p>After more than two years of development, the version 5 of the Jaxon library is finally out!</p><p>This release is an important step that I think will bring the Jaxon library to the next level, because it implements the features I hoped the library had when I started developing and using it more than ten years ago.</p><p>So what’s new in this release?</p><ul><li>Exported PHP classes are now called components, and they can be of three different types. Some components can be attached to DOM nodes, and used to set their content.</li><li>The <em>call factories</em> in PHP have been enriched, and now support calls to Javascript functions and event handlers, as well as their parameters.</li><li>The command names and formats in responses are now more meaningful, and their processing in Javascript is improved. Deprecated commands have also been removed.</li><li>The dialog libraries now contain only Javascript code, in a single and tiny object. They will therefore be much easier to create and maintain.</li></ul><p>Now let’s dive more in depth into each of these new features.</p><h4><strong>The Jaxon components</strong></h4><p>In the previous versions of Jaxon, the webpage content was set exclusively using the HTML <em>id</em> attribute.</p><pre>$this-&gt;response-&gt;html(&#39;dom-element-id&#39;, $text);</pre><p>Each DOM element with dynamic content in a webpage needed to be given a unique id, which will then be used to update its content. Keeping track of all those ids in an application was not an easy task.</p><p>Jaxon 5 introduces a new <a href="https://www.jaxon-php.org/docs/v5x/components/node-components.html">UI component</a>, which is a Jaxon class that defines the content of a DOM element. It just needs to implement a method named <em>html()</em>,</p><pre>namespace Jaxon\Demo\Calc\App;<br><br>class Calc extends \Jaxon\App\NodeComponent<br>{<br>    public function html(): \Stringable<br>    {<br>        return $this-&gt;view()-&gt;render(&#39;jaxon::demo::calc::calc&#39;);<br>    }<br>}</pre><p>and to be bound to a DOM element in a webpage.</p><pre>&lt;div &lt;?= attr()-&gt;bind(rq(Jaxon\Demo\Calc\App\Calc::class)) ?&gt;&gt;<br>&lt;/div&gt;</pre><p>The <em>render()</em> method in the component can then be used to set the DOM element content, for example with an event handler.</p><pre>&lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot; &lt;?=<br>    attr()-&gt;click(rq(Jaxon\Demo\Calc\App\Calc::class)-&gt;render()) ?&gt;&gt;Clear&lt;/button&gt;</pre><p>In this example, a click on the button will display the <em>jaxon::demo::calc::calc</em> view in the <em>div</em> element the UI component is bound to.</p><p>The new components now make it very easy to build complex UI with Jaxon.</p><h4><strong>The call and selector factories</strong></h4><p>Since one of the core features of Jaxon is to write UI components code in PHP on the server, it is important to be able to make calls to Javascript functions, define event handlers, and last but not the least, pass the contents of the webpage as parameters to those calls. That’s the role of the <em>call factories</em>.</p><p>The <em>call factories</em> have been around since the version 2, initially as the <a href="https://www.jaxon-php.org/docs/v2x/advanced/jquery.html">JQuery PHP API</a>. They have evolved a lot since then, and now they can make calls to the exported Jaxon classes, or to any Javascript function or object. They can also define event handlers on the webpage elements using Javascript or JQuery-style selectors. Thirdly, they also provides functions to pass any content of the webpage as parameter to Javascript calls.</p><p>In this code from the Jaxon examples, JQuery selectors are used in a Jaxon custom HTML attribute to define calls to Jaxon classes as event handlers on two select lists, and to pass the selected item value as parameter to the handler.</p><pre>&lt;div class=&quot;row&quot; &lt;?= attr()<br>    -&gt;select(&#39;.app-color-choice&#39;)<br>        -&gt;on(&#39;change&#39;, rq(AppTest::class)-&gt;setColor(jq()-&gt;val()))<br>    -&gt;select(&#39;.ext-color-choice&#39;)<br>        -&gt;on(&#39;change&#39;, rq(ExtTest::class)-&gt;setColor(jq()-&gt;val())) ?&gt;&gt;</pre><p>In this other example, a command is added in a response to make a call to the <em>Tontine.makeTableResponsive(‘content-planning-charge-page’)</em> Javascript code in the browser.</p><pre>$this-&gt;response-&gt;jo(&#39;Tontine&#39;)<br>    -&gt;makeTableResponsive(&#39;content-planning-charge-page&#39;);</pre><p>When building an application UI on the server, being able to make Javascript calls and set event handlers in a webpage is paramount, and the <em>call factories</em> provide Jaxon with a powerful set of features to achieve that quite easily.</p><h4><strong>Javascript library rewrite</strong></h4><p>The Javascript library rewrite started as a discusion on Github about <a href="https://github.com/jaxon-php/jaxon-js/issues/21">the forbidden usage of eval function</a>.</p><p>I then decided to rewrite the Javascript library, which today has resulted in many important changes.</p><p>The library now includes a command processor which executes existing Javascript functions from a JSON payload. With this processor, there’s no need for the <em>eval</em> function anymore, and it is also at the foundation of the <em>call factories</em> described above.</p><p>The library also includes an attribute processor, which handles the Jaxon custom attributes needed to implement the UI components bindings and the event handlers.</p><p>In the example above where the <em>Jaxon\Demo\Calc\App\Calc</em> UI Component is bound to a <em>div</em> element, the following HTML code is actually generated.</p><pre>&lt;div jxn-bind=&quot;Jaxon.Demo.Calc.App.Calc&quot;&gt;<br>...<br>&lt;/div&gt;</pre><p>The <a href="https://www.jaxon-php.org/docs/v5x/features/responses.html">response commands</a> were also rewritten with new names and a new JSON format. Their names are now more meaningful, and the obsolete ones were removed.</p><h4><strong>The Dialog plugin</strong></h4><p>The <a href="https://www.jaxon-php.org/docs/v5x/ui-features/dialogs.html">Dialog plugin</a> is a special case in the Jaxon universe. It is a Jaxon response plugin, but at the same time it can also be extended with it own plugins.</p><p>In the previous version, adding a dialog plugin required to write functions in both PHP and Javascript. In the v5 release, only a tiny Javascript object is now necessary.</p><p>This is for example the code of the <a href="https://notifyjs.jpillora.com/">Notify</a> library integration, which implements the alert function.</p><pre>jaxon.dom.ready(() =&gt; jaxon.dialog.register(&#39;notify&#39;, (self, options) =&gt; {<br>    // Dialogs options<br>    const {<br>        alert: alertOptions = {},<br>    } = options;<br><br>    const xTypes = {<br>        success: &#39;success&#39;,<br>        info: &#39;info&#39;,<br>        warning: &#39;warn&#39;,<br>        error: &#39;error&#39;,<br>    };<br><br>    /**<br>     * Show an alert message<br>     *<br>     * @param {object} alert The alert parameters<br>     * @param {string} alert.type The alert type<br>     * @param {string} alert.message The alert message<br>     *<br>     * @returns {void}<br>     */<br>    self.alert = ({ type, message }) =&gt; {<br>        $.notify(message, {<br>            ...alertOptions,<br>            className: xTypes[type] ?? xTypes.info,<br>            position: &quot;top center&quot;,<br>        });<br>    };<br>}));</pre><p>The only feature in PHP classes is to load the Javascript files into the webpage.</p><h4><strong>The examples</strong></h4><p>A <a href="https://www.jaxon-php.org/docs/v5x/about/example.html">new example</a> is introduced to illustrate the Jaxon operation.</p><p>The example now implements a simple calculator, which takes an operation and two operands as parameters, performs the calculation using an injected service, and displays the result.</p><p>There are two text zones and a select combo for the inputs, and the result is displayed in a readonly text zone.</p><p>The example is built with the new Jaxon UI components, and also released as a <a href="https://github.com/jaxon-php/jaxon-demo-calc">Jaxon package</a>.</p><p>This package is used in the <a href="https://github.com/jaxon-php/jaxon-demo-laravel">Laravel</a>, <a href="https://github.com/jaxon-php/jaxon-demo-symfony">Symfony</a> and <a href="https://github.com/jaxon-php/jaxon-demo-slim">Slim Framework</a> demo applications, to show how the Jaxon library can be used to build a cross-framework and full-featured package including both the frontend and backend features.</p><p>The <a href="https://github.com/lagdo/dbadmin-mono">DB Admin</a> package and the <a href="https://github.com/lagdo/tontine">African Tontine</a> application are also upgraded to Jaxon 5. Although the former is still a work in progress, both are real world examples of building complex one page Ajax applications with Jaxon.</p><h4><strong>Conclusion</strong></h4><p>The new Jaxon 5 release is packed with features that make it a good choice for creating complex Ajax applications with PHP on the server side.</p><p>There are UI components to build the webpage, custom attributes to enrich the HTML code, and powerful <em>call factories</em> to make calls to all kind of Javascript functions in PHP.</p><p>In addition to the <a href="https://www.jaxon-php.org/docs.html">documentation</a>, there are <a href="https://github.com/jaxon-php/jaxon-examples">many examples</a> in PHP or with framework integration, and real world open source applications using the library.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22e551ea5f4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parallel batch processing with Temporal]]></title>
            <link>https://medium.com/@thierry.feuzeu/parallel-batch-processing-with-temporal-b10ae89e7269?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b10ae89e7269</guid>
            <category><![CDATA[durable-workflow]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[batch-processing]]></category>
            <category><![CDATA[temporal]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Mon, 07 Apr 2025 16:54:29 GMT</pubDate>
            <atom:updated>2025-04-08T13:42:50.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVO2piUvPZdLN6Cv47MfRw.png" /></figure><p><a href="https://temporal.io/">Temporal</a> is a durable execution platform that makes it easier to build and operate reliable, scalable applications. It provides <a href="https://docs.temporal.io/develop/">many native SDKs</a> allowing the developers to write the business logic in their applications in a language they are already used with.</p><p>While the Temporal’s SDK ability to abstract away the complexities of distributed systems makes it more suitable for complex applications, the provided reliability and scalability can also benefit to simpler use cases.</p><p>As an example, below is an implementation of a simple parallel batch with the Temporal PHP SDK. Even if all the example codes are in PHP, the same concepts apply to other supported languages.</p><h3>The batch definition</h3><p>The batch applies the same processing to a given number of items. It takes a batch id and an optional array of options as input. The batch items are processed in parallel, but for each item there is a set of tasks to be executed sequentially.</p><p>After all the items are processed, a closing task is executed, for example to notify the batch termination and results availability.</p><p>Each of the sub-task of a batch item can fail, and such a failure must trigger the retry of that single sub-task, and not those which already terminated successfully.</p><h3>The batch workflow</h3><p>The workflow implements the interface below.</p><pre>#[WorkflowInterface]<br>interface SimpleBatchWorkflowInterface<br>{<br>    #[WorkflowMethod(name: &quot;SimpleBatch&quot;)]<br>    public function start(int $batchId, array $options);<br><br>    #[QueryMethod]<br>    public function getAvailableResults(): array;<br><br>    #[QueryMethod]<br>    public function getPendingTasks(): array;<br>}</pre><p>In addition to the workflow start() method, there are two <a href="https://docs.temporal.io/develop/php/message-passing#queries">query methods</a> that will give real time access to the workflow execution status.</p><p>This is the <a href="https://docs.temporal.io/develop/php/temporal-clients#start-workflow-execution">workflow method</a> skeleton.</p><pre>    public function start(int $batchId, array $options)<br>    {<br>        // Get the item ids<br>        ...<br><br>        foreach($itemIds as $itemId)<br>        {<br>            // Process the batch item asynchronously.<br>            Workflow::async(<br>                function() {<br>                    // Run the batch item tasks.<br>                    ...<br>                }<br>            );<br>        }<br><br>        // Wait for all the async calls to terminate.<br>        ...<br><br>        return $results;<br>    }</pre><p>The list of items to be processed are not included in the workflow input. So they first need to be retrieved, using the batch id and the optional options. The functions processing the items are then started asynchronously. Finally, the workflow waits for all these functions to terminate, runs some post-processing task, and returns their results in an array.</p><h3>The batch item processing</h3><p>The Workflow::async() function <a href="https://docs.temporal.io/develop/php/asynchronous-activity-completion">asynchronously executes a set of activities</a> defined in a callback and returns a promise that will be resolved to the value returned by the callback.</p><p>In this example, each callback function executes 3 tasks sequentially, as follow.</p><pre>    // Run the batch item tasks.<br>    Workflow::async(<br>        function() use($itemId, $batchId) {<br>            // Notify the item processing start.<br>            yield $this-&gt;batchActivity-&gt;itemProcessingStarted($itemId, $batchId);<br><br>            $output = yield $this-&gt;batchActivity-&gt;processItem($itemId, $batchId);<br><br>            // Notify the item processing end.<br>            yield $this-&gt;batchActivity-&gt;itemProcessingEnded($itemId, $batchId);<br>        }<br>    );</pre><blockquote>In order to demonstrate the failure and retry handling, the processItem() method <a href="https://github.com/feuzeu/temporal-symfony-samples/blob/b3c012f41de98fce781ee26d35447d83db00cb82/apps/all-in-one/src/Service/SimpleBatch/SimpleBatchService.php#L73">in the example</a> randomly returns an integer or throws an error.</blockquote><h3>A first implementation</h3><p>A simple implementation of the batch will start the items processing asynchronously, store the corresponding promises in an array, then <em>yield</em> on the promises to get the results.</p><pre>    public function start(int $batchId, array $options)<br>    {<br>        $itemIds = yield $this-&gt;batchActivity-&gt;getBatchItemIds($batchId);<br><br>        $promises = [];<br>        foreach($itemIds as $itemId)<br>        {<br>            $promises[$itemId] = Workflow::async(<br>                function() use($itemId, $batchId) {<br>                    // Set the item processing as started.<br>                    yield $this-&gt;batchActivity-&gt;itemProcessingStarted($itemId, $batchId);<br><br>                    // This activity randomly throws an exception.<br>                    $output = yield $this-&gt;batchActivity-&gt;processItem($itemId, $batchId);<br><br>                    // Set the item processing as ended.<br>                    yield $this-&gt;batchActivity-&gt;itemProcessingEnded($itemId, $batchId);<br><br>                    return $output;<br>                }<br>            );<br>        }<br><br>        // Wait for all the async calls to terminate.<br>        $this-&gt;results = [];<br>        for($promises as $itemId =&gt; $promise)<br>        {<br>            $this-&gt;results[$itemId] = yield $promise;<br>        }<br>        return $this-&gt;results;<br>    }</pre><p>But there are two main issues with this implementation.</p><p>First, the errors are not handled. If a workflow triggers an error, the promise loop will end up hanging indefinitely.</p><p>Then, the results are made available in the same order the items processing are started. A terminated batch item will not be <em>yield</em>’ed until all the items that were started before are also terminated, adding a delay between when a result is ready, and when it is actually available for read.</p><h3>Using the Promise API</h3><p>The Workflow::async() call returns a <a href="https://reactphp.org/promise/">React promise</a> object that can be provided with 3 callbacks, which we will use to handle tasks error and termination.</p><pre>    $promise-&gt;then(onFulfilled, onRejected)<br>        -&gt;always(onFulfilledOrRejected);</pre><ul><li><strong>onFulfilled</strong>: called if the task has succeeded.</li><li><strong>onRejected</strong>: called if the task has failed.</li><li><strong>onFulfilledOrRejected</strong>: called when the task has ended, regardless of it result.</li></ul><p>Using these callbacks, we are now able to store the batch items results as soon as they are available. A single call to Promise::all() can then be used to wait for all the asynchronous calls to terminate.</p><pre>    $promises = [];<br>    foreach($itemIds as $itemId)<br>    {<br>        $this-&gt;pending[$itemId] = true;<br>        $promises[$itemId] = Workflow::async(<br>            function() use($itemId, $batchId) {<br>                ...<br><br>                return $output;<br>            }<br>        )<br>        -&gt;then(<br>            fn($output) =&gt; $this-&gt;results[$itemId] = [<br>                &#39;success&#39; =&gt; true,<br>                &#39;output&#39; =&gt; $output,<br>            ],<br>            fn(Throwable $e) =&gt; $this-&gt;results[$itemId] = [<br>                &#39;success&#39; =&gt; false,<br>                &#39;message&#39; =&gt; $e-&gt;getMessage(),<br>            ]<br>        )<br>        -&gt;always(fn() =&gt; $this-&gt;pending[$itemId] = false);<br><br>        // Wait for all the async calls to terminate.<br>        yield Promise::all($promises);<br>    }</pre><blockquote>Note: the always() method is deprecated and replaced by the finally() method in the <a href="https://reactphp.org/promise/#promiseinterfacealways">version 3 of the React promise</a> library.</blockquote><p><strong>The workflow and activity options</strong></p><p>Some <a href="https://docs.temporal.io/develop/php/failure-detection#activity-timeouts">Temporal PHP SDK options</a> need to be set for the workflow to operate properly.</p><p>Depending on the numbers of batch items and workflow workers, there might be a delay between the moment an activity is scheduled and when it is started. A timeout must be set with the withScheduleToStartTimeout() method of the ActivityOptions class.<br>An appropriate value also needs to be set for the activity duration, depending on how they perform. The corresponding timeouts are set with the withScheduleToCloseTimeout() and withStartToCloseTimeout() methods of the same class.</p><p>Since the tasks in the workflow can randomly fail and need to be retried, the options for the retry policy also need to be provided. The maximum attempts, initial and maximum interval are set using the withMaximumAttempts(), withInitialInterval() and withMaximumInterval() of the RetryOptions class.</p><p>The above options are set on the activity processes.</p><pre>    $this-&gt;batchActivity = Workflow::newActivityStub(<br>        SimpleBatchActivityInterface::class,<br>        ActivityOptions::new()<br>            -&gt;withStartToCloseTimeout(CarbonInterval::hours(6))<br>            -&gt;withScheduleToStartTimeout(CarbonInterval::hours(1))<br>            -&gt;withScheduleToCloseTimeout(CarbonInterval::hours(6))<br>            -&gt;withRetryOptions(<br>                RetryOptions::new()<br>                    -&gt;withMaximumAttempts(100)<br>                    -&gt;withInitialInterval(CarbonInterval::second(10))<br>                    -&gt;withMaximumInterval(CarbonInterval::seconds(100))<br>            )<br>    );</pre><p>The last option to set is the entire batch execution timeout, which is set on the workflow process.</p><pre>    $workflow = $this-&gt;workflowClient-&gt;newWorkflowStub(<br>        SimpleBatchWorkflowInterface::class,<br>        WorkflowOptions::new()<br>            -&gt;withWorkflowExecutionTimeout(CarbonInterval::week())<br>    );</pre><h3>Wrapping up</h3><p>The following workflow class is a complete implementation of a parallel batch processing with the <a href="https://docs.temporal.io/develop/php">Temporal PHP SDK</a>, which also provides real time access to the status and results of the running tasks.</p><pre>use Carbon\CarbonInterval;<br>use Temporal\Activity\ActivityOptions;<br>use Temporal\Common\RetryOptions;<br>use Temporal\Promise;<br>use Temporal\Workflow;<br>use Throwable;<br><br>class SimpleBatchWorkflow implements SimpleBatchWorkflowInterface<br>{<br>    /**<br>     * @var array<br>     */<br>    private array $results = [];<br><br>    /**<br>     * @var array<br>     */<br>    private array $pending = [];<br><br>    /**<br>     * @var SimpleBatchActivityInterface<br>     */<br>    private $batchActivity;<br><br>    public function __construct()<br>    {<br>        $this-&gt;batchActivity = Workflow::newActivityStub(<br>            SimpleBatchActivityInterface::class,<br>            ActivityOptions::new()<br>                -&gt;withStartToCloseTimeout(CarbonInterval::hours(6))<br>                -&gt;withScheduleToStartTimeout(CarbonInterval::hours(1))<br>                -&gt;withScheduleToCloseTimeout(CarbonInterval::hours(6))<br>                -&gt;withRetryOptions(<br>                    RetryOptions::new()<br>                        -&gt;withMaximumAttempts(100)<br>                        -&gt;withInitialInterval(CarbonInterval::second(10))<br>                        -&gt;withMaximumInterval(CarbonInterval::seconds(100))<br>                )<br>        );<br>    }<br><br>    /**<br>     * @inheritDoc<br>     */<br>    public function start(int $batchId, array $options)<br>    {<br>        // Notify the batch processing start.<br>        yield $this-&gt;batchActivity-&gt;batchProcessingStarted($batchId, $options);<br><br>        $itemIds = yield $this-&gt;batchActivity-&gt;getBatchItemIds($batchId, $options);<br><br>        $promises = [];<br>        foreach($itemIds as $itemId)<br>        {<br>            // Set the batch item as pending.<br>            $this-&gt;pending[$itemId] = true;<br>            // Process the batch item.<br>            $promises[$itemId] = Workflow::async(<br>                function() use($itemId, $batchId) {<br>                    // Notify the item processing start.<br>                    yield $this-&gt;batchActivity-&gt;itemProcessingStarted($itemId, $batchId);<br><br>                    // This activity randomly throws an exception.<br>                    $output = yield $this-&gt;batchActivity-&gt;processItem($itemId, $batchId);<br><br>                    // Notify the item processing end.<br>                    yield $this-&gt;batchActivity-&gt;itemProcessingEnded($itemId, $batchId);<br><br>                    return $output;<br>                }<br>            )<br>            -&gt;then(<br>                fn($output) =&gt; $this-&gt;results[$itemId] = [<br>                    &#39;success&#39; =&gt; true,<br>                    &#39;output&#39; =&gt; $output,<br>                ],<br>                fn(Throwable $e) =&gt; $this-&gt;results[$itemId] = [<br>                    &#39;success&#39; =&gt; false,<br>                    &#39;message&#39; =&gt; $e-&gt;getMessage(),<br>                ]<br>            )<br>            // We are calling always() instead of finally() because the Temporal PHP SDK depends on<br>            // react/promise 2.9. Will need to change to finally() when upgrading to react/promise 3.x.<br>            -&gt;always(fn() =&gt; $this-&gt;pending[$itemId] = false);<br>        }<br><br>        // Wait for all the async calls to terminate.<br>        yield Promise::all($promises);<br><br>        // Notify the batch processing end.<br>        yield $this-&gt;batchActivity-&gt;batchProcessingEnded($batchId, $this-&gt;results);<br><br>        return $this-&gt;results;<br>    }<br><br>    /**<br>     * @inheritDoc<br>     */<br>    public function getAvailableResults(): array<br>    {<br>        return $this-&gt;results;<br>    }<br><br>    /**<br>     * @inheritDoc<br>     */<br>    public function getPendingTasks(): array<br>    {<br>        return array_keys(array_filter($this-&gt;pending, fn($pending) =&gt; $pending));<br>    }<br>}</pre><p>Two sample applications including this workflow are available in these Github repo: <a href="https://github.com/feuzeu/temporal-symfony-samples">Temporal samples for Symfony</a> and <a href="https://github.com/feuzeu/temporal-samples-php">Temporal PHP SDK samples</a>.</p><p>Below are some screenshots of the Temporal UI when the workflow is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wR0qaDUJGOdO7WkQu-OjAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wWSv1Hy3RCMTsiaXEQj3g.png" /></figure><p>How the user actually interacts with the workflow will depend on the PHP application.</p><p>While <a href="https://github.com/feuzeu/temporal-symfony-samples">this sample Symfony application</a>, provides a REST API and a Swagger generated web page, while <a href="https://github.com/feuzeu/temporal-samples-php">this other example</a>, cloned from the <a href="https://github.com/temporalio/samples-php">Temporal PHP SDK samples</a>, provides CLI commands.</p><p>In both applications, the simple batch sample allows the user to start a workflow and display its status in real time.</p><p>Below is an overview of a running workflow status in the Swagger UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eX4AvSi7tVw-BB1PhDV3ug.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b10ae89e7269" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using service facades in a Symfony application — part 2]]></title>
            <link>https://medium.com/@thierry.feuzeu/using-service-facades-in-a-symfony-application-part-2-9a3804afdff2?source=rss-a1e957e5b61b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a3804afdff2</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[service-container]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[facade]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Thierry Feuzeu]]></dc:creator>
            <pubDate>Thu, 27 Mar 2025 10:57:47 GMT</pubDate>
            <atom:updated>2025-03-27T10:57:47.615Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using service facades in a Symfony application — part 2</h3><p>In the <a href="https://medium.com/@thierry.feuzeu/using-service-facades-in-a-symfony-application-part-1-971867d74ab5">first part of this article</a>, I have discussed what service facades are and what they are not, and came to the conclusion that service facades are just a different implementation of the dependency injection pattern.</p><p>In this second part, I’ll present a couple of cases where using a service facade may be your best choice as a developer.</p><p>Before going any further, please don’t get me wrong. In most cases, using the IoC based dependency injection will be the way to go. However, it is not a panacea, there are some cases where using a service facade might be the best way, or even the only way, to implement dependency injection in a Symfony application.</p><h4>This is an utility, Sir. Not a service.</h4><p>Dependency injection is everywhere in the Symfony framework. Any object that requires another only need to declare it as a dependency, and it will be injected by the framework. That includes the services, but not only. Some other objects that may be better defined as utilities rather than services, are also injected by the Symfony framework.</p><p>The most widely used objects in this case are the logger and the view renderer. The former is used almost everywhere in an application, and having to inject it just makes it usage more cumbersome, especially when debugging the application. A global function which returns an instance of a logger would be more than welcome, and nobody would complain about adding a global state in the application.</p><pre>public function doSomething()<br>{<br>  logger()-&gt;debug(&#39;Quite simple.&#39;);<br>}</pre><p>In addition to debugging, error reporting is another use case where using a service facade may be the better solution.</p><pre>// With IoC<br>public function doSomething()<br>{<br>  try {<br>    //<br>  } catch (Exception $e) {<br>    $this-&gt;logger-&gt;error(&#39;Something went wrong.&#39;, [<br>      &#39;message&#39; =&gt; $e-&gt;getMessage()<br>    ]);<br>  }<br>}</pre><pre>// With a service facade<br>public function doSomething()<br>{<br>  try {<br>    //<br>  } catch (Exception $e) {<br>    Logger::error(&#39;Something went wrong.&#39;, [<br>      &#39;message&#39; =&gt; $e-&gt;getMessage()<br>    ]);<br>  }<br>}</pre><p>In the above example, hopefully the code will run millions or more times without an error. A facade will then save the application millions of useless parameter instantiation and passing.</p><h4>Lazy objects</h4><p>The recommended solution in a Symfony application to prevent from unnecessarily create objects that are heavy to instantiate is to use lazy objects.</p><p>As stated in <a href="https://symfony.com/doc/current/service_container/lazy_services.html">their documentation</a>, <em>Under the hood, proxies generated to lazily load services inherit from the class used by the service</em>. Which leads to the already documented limitation: it cannot be used with final or readonly classes.</p><p>Besides those limitations, let’s see together what happens under the hood when a lazy service is defined. Since the proxy inherits from the service class, the only way not to have the service methods directly available inside is to rewrite them on-the-fly. Because these methods are available and public in the proxy, it is then impossible to use PHP magic methods.</p><p>Creating a proxy class then requires to retrieve all the public methods of the service class, probably using a reflection class, and for each of them to create another method with the same signature that will get the service from the DI container and forward the call.</p><p>So even if using a lazy service seems easy, it actually involves lot of processing with automatically generated code.</p><p>On the other side, a service facade, by making use of PHP magic functions, provides a more simple and elegant solution. The whole feature is implemented (<a href="https://github.com/lagdo/symfony-facades">https://github.com/lagdo/symfony-facades</a>) with less than 200 lines of code, comments and empty lines included.</p><h4>The cases where IoC is impossible</h4><p>As I already stated, the dependency injection implementation in the Symfony framework is strongly coupled with the inversion of control (IoC) pattern. As a consequence, and it is from my point of view the most important limitation of the Symfony service container, the dependency injection can only be used in the user functions that are called by the framework, for example the class constructors.</p><p>So if for any reason, a given class is instantiated, with the <strong><em>new</em></strong> keyword, somewhere in an application, it will not be possible to use the IoC based dependency injection in that class.</p><p>I’ve found two real world examples matching that case.</p><p>The first one is the paginator in Symfony. There are some examples <a href="https://api-platform.com/docs/guides/custom-pagination">here</a> and <a href="https://medium.com/@kekekuza/pagination-in-symfony-a5d60fe6833a">here</a>.</p><pre>// Get total results and paginated results<br>$paginator = new Paginator($queryBuilder);</pre><p>Since the developer needs to instantiate the paginator class by himself, the only way to have a service available in a custom paginator class is to inject that service in the caller class and then pass it to the paginator. Symfony just can’t inject a dependency directly in a custom paginator.</p><p>The second example is the <a href="https://docs.temporal.io/develop/php">Temporal PHP SDK</a>. When <a href="https://docs.temporal.io/develop/php/core-application#run-a-dev-worker">implementing a workflow with Temporal</a>, the workflow classes are registered in a worker by providing their class name.</p><pre>// Workflows are stateful. So you need a type to create instances.<br>$worker-&gt;registerWorkflowTypes(App\DemoWorkflow::class);</pre><p>The Temporal SDK will then instantiate the workflow class when it will need to be executed.<br>Unlike the previous case, the developer doesn’t even have the opportunity to pass anything to the constructor. It is then absolutely impossible to use IoC based dependency injection in a workflow class, and thus to register activity classes, which are called by workflow classes, in the Symfony service container.</p><p>In <a href="https://github.com/feuzeu/temporal-symfony-samples">this package</a> of mine which provides sample Symfony applications running Temporal durable workflows, the only way for me to have workflow and activity classes implemented following the Symfony philosophy, means they are configured in the service container and injected in the application, was to make use of service facades.</p><h3>Conclusion</h3><p>After a first part which discussed what facades are and what they are not, in this second part, I’ve hightlighted a few cases where using a service facade is the the best, or even the only option.</p><p>I hope this will help Symfony developers to make a better decision about wether or when they should use service facades in their applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a3804afdff2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>