<?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 RBFraphael on Medium]]></title>
        <description><![CDATA[Stories by RBFraphael on Medium]]></description>
        <link>https://medium.com/@rbfraphael?source=rss-54d6de6b846b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XBPyHifxZQRc-Gl1xFhsiw.jpeg</url>
            <title>Stories by RBFraphael on Medium</title>
            <link>https://medium.com/@rbfraphael?source=rss-54d6de6b846b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:14:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rbfraphael/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[Using Xampp on Windows? Try Local.Host instead]]></title>
            <link>https://rbfraphael.medium.com/using-xampp-on-windows-try-local-host-instead-af0c0dbf2a45?source=rss-54d6de6b846b------2</link>
            <guid isPermaLink="false">https://medium.com/p/af0c0dbf2a45</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[RBFraphael]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 17:33:29 GMT</pubDate>
            <atom:updated>2023-12-29T17:33:29.880Z</atom:updated>
            <content:encoded><![CDATA[<p>Even if you’re using other simple solutions (like WAMP or Laragon), you should give Local.Host a try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*ZPIZ4cBXuupoMfqjlv_8vw.png" /><figcaption>Local.Host admin panel, on the About tab</figcaption></figure><p><a href="https://github.com/rbfraphael/localdothost">Local.Host</a> is my personal project to replace <a href="https://www.apachefriends.org/">Xampp</a> on Windows, and other local environment softwares for PHP developers and others. It was born from the needs of my team to have more than one PHP version available to run projects. They all used Xampp for a long time (for those that are wondering “why not using <a href="https://www.docker.com/">Docker</a>?” or “why not using <a href="https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux">WSL</a>” or anything else, the team has a lot of small projects, hosted mostly on shared hosting providers — such as <a href="https://www.hostinger.com/">Hostinger</a>, <a href="https://www.godaddy.com/">GoDaddy</a>, <a href="https://hostgator.com/">Hostgator</a> etc — and they are mostly junior devs starting on the programming), and, when some project needs to run on a different version than the installed with their Xampp, it was a mess to update or re-install Xampp with the correct version. It also occurs with some <a href="https://nodejs.org/">Node</a> projects.</p><p>I’m a Linux user, and I have a specific setup for running PHP and Node projects. I use NVM for managing Node versions, and I have a Apache + PHP-FPM setup to have multiple PHP versions available, allowing me to specify each project it’s own PHP version through the .htaccess file. Also, I have a simple DNS setup with dnsmask, which allows me to have dynamic sub-domains on my machine, only needing to create a folder and <em>voila!</em>, there’s a new subdomain with the name of the created folder.</p><p>Analysing my own setup, I started searching some way to make a Windows setup with these same features. Apache with multiple PHP, configured by .htaccess, a DNS setup with dynamic subdomains, and NVM for multiple Node versions. And I figured out how to do that with some open-source and/or free tools (<a href="https://www.apachelounge.com/">Apache Lounge </a>with <a href="https://www.apachelounge.com/viewtopic.php?p=25673">FastCGI</a>, <a href="https://windows.php.net/">PHP for Windows</a> with PHP-CGI, <a href="https://www.phpmyadmin.net/">phpMyAdmin</a>, <a href="https://mariadb.org/">MariaDB</a>, <a href="https://github.com/coreybutler/nvm-windows">NVM for Windows</a> and <a href="https://mayakron.altervista.org/support/acrylic/Home.htm">Acrylic DNS</a>). But, since the people on my team are mostly junior devs (that sometimes avoid using cli commands), I thought it would be difficult to explain how to make this environment. So, what is the best way to easily build a very useful and feature-rich dev environment on Windows with some tools and their configurations? Since I’m a developer, let’s develop a solution for that!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*2lsc1ucWWjHe2Abj-tvYXA.gif" /><figcaption>Gif image typing “let’s code a better world” — from <a href="https://giphy.com/gifs/dbsppro-dbsp-be-a-peer-lets-code-better-world-tJDz8mPYyUJZ1Pg9fA">Giphy</a></figcaption></figure><p>This way, I started a project called Local.Host (the name comes from my own setup, which every subdomain has a .local.host suffix — example.local.host) using <a href="https://www.electronjs.org/">Electron</a> and some Windows’ tricks. At the earlier versions, Local.Host was just a pre-configured Apache with FastCGI, built-in multiple PHP versions, MariaDB as a database server and phpMyAdmin for managing databases. But it grew up fast, and now it includes <a href="https://www.mongodb.com/">MongoDB</a> as a NoSQL database, I’ve built a GUI for managing NVM (since NVM for Windows is only a command-line tool), it comes with <a href="https://getcomposer.org/">Composer</a> and PHP-CLI commands available, <a href="https://www.heidisql.com/">HeidiSQL</a> as a lightweight alternative for phpMyAdmin (that doesn’t need to have Apache running in parallel), built-in <a href="https://www.mongodb.com/products/tools/compass">MongoDB Compass</a> for managing MongoDB databases, <strong>a loving dark mode</strong>… Yeah, that’s a lot of things on one software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*ycKPZbJXwn9EEw9KM-pB8g.png" /><figcaption>Local.Host Admin Panel on NVM GUI Interface</figcaption></figure><p>Local.Host itself is the admin panel application that centers all of features, and makes it easier to access the built-in tools and their settings. Also, the bundled tools (like Apache, PHP, MariaDB, Acrylic, MongoDB etc) has it’s own configuration, pre-made by me and well-included on Local.Host, all accessible through the Local.Host Admin Panel.</p><p>Now, I see Local.Host more as <em>“the only software you need to build your local development environment”</em> than <em>“a Xampp alternative for PHP developers”</em>. And I’m very happy with this project, because I’ve learned a lot with him, and my team members are using it (and loving it). I’m very proud of myself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ED-Df2aqHXBpJafy4si4Tg.gif" /><figcaption>Happy man jumping, with a text saying “I did it!” — from <a href="https://giphy.com/gifs/travisband-travis-fran-healy-gjiE1RizLmRCBZ3cbW">Giphy</a></figcaption></figure><p>Now, I want to invite you to meet Local.Host and give it a try. The source code is fully available on <a href="https://github.com/rbfraphael">my personal GitHub profile</a>, where you can download the latest release and fork (and hack) the code as you want. Feel free, also, to give feedbacks, suggestions and any other comment (even if they are negative — I will try to interpret it as constructive criticism).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af0c0dbf2a45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Desktop Apps with Electron + Next.JS (without Nextron)]]></title>
            <link>https://rbfraphael.medium.com/building-desktop-apps-with-electron-next-js-without-nextron-01bbf1fdd72e?source=rss-54d6de6b846b------2</link>
            <guid isPermaLink="false">https://medium.com/p/01bbf1fdd72e</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[electronjs]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[RBFraphael]]></dc:creator>
            <pubDate>Sun, 03 Dec 2023 06:15:20 GMT</pubDate>
            <atom:updated>2024-01-20T19:59:18.723Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*UFjN4Skw98uNucU3x1WUdw.png" /></figure><h3>A bit of story first</h3><p>Some time ago I’ve started a personal project called Local.Host, which was a replacement alternative for XAMPP, for PHP developers using Windows. Due to my extensive knowledge of web development, I decided to use Electron for building the desktop app, alongside with some Windows’ CMD commands and tricks.</p><p>After some search, I’ve found Nextron, a good Next.JS + Electron boilerplate. But, today, I’ve noticed by some friends that my software is a bit heavy, sometimes freezing. Understanding more about Electron, I’ve noticed that Nextron comes with an old version of both Electron and Next.JS, and some “internal” mechanisms used are causing slow downs on my application.</p><p>To not fully rewrite the app, I tried to “create” my own Next.JS + Electron project, with latest versions of both and, obviously, more lightweight than Nextron.</p><p>So, now, I have a (I personally consider it) very solid guide for creating desktop apps with these techs. And, of couse, I decided to share it with you, because I’ve found a lot of people that are searching for something like that and are all with the same opinion about Nextron.</p><h3>The guide</h3><h4>Step 1 — Start a Next.JS project</h4><p>Start with Next.JS. First, run the traditional command npx create-next-app@latest &lt;your_project_name&gt;. Set the preferences you want durint setup. The only setting you need to take care is to use the <strong>Pages Router</strong> instead pp Router, since the App Router will not work as expected (I’ll talk more about this after the guide).</p><pre>npx create-next-app@latest electron-nextjs-project</pre><h4>Step 2 — Install Electron and other dependencies</h4><p>cd into your project folder (in this example, electron-nextjs-project) and install the following dependencies, with both following commands:</p><p>Dev dependencies:</p><pre>npm install --save-dev electron electron-builder concurrently</pre><p>Project dependencies:</p><pre>npm install electron-serve</pre><h4>Step 3 — Setting up package.json</h4><p>Start opening the package.json file with your preferred text editor or IDE. You need to modify the build and dev scripts, and add the main property. The concurrently we installed before will be used to run both Next.JS and Electron in parallel during the development, and you need to point the main script to the entrypoint of your Electron application. Also, we need to add &quot;author&quot; and &quot;description&quot; attributes, both needed when building the application executables.</p><pre>{<br>  ...<br>  &quot;main&quot;: &quot;main/main.js&quot;,<br>  &quot;author&quot;: &quot;RBFraphael&quot;,<br>  &quot;description&quot;: &quot;Electron + NextJS example project&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;concurrently -n \&quot;NEXT,ELECTRON\&quot; -c \&quot;yellow,blue\&quot; --kill-others \&quot;next dev\&quot; \&quot;electron .\&quot;&quot;,<br>    &quot;build&quot;: &quot;next build &amp;&amp; electron-builder&quot;,<br>    ...<br>  }<br>  ...<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*EXsn9iW0HTki7JQ84yAlsA.png" /></figure><p>As you can see, when developing with npm run dev will start both Next.JS and Electron (you can find more details about Concurrently <a href="https://www.npmjs.com/package/concurrently">here</a>), and, when building your application with npm run build it will build the Next.JS files, then the Electron application (find more information about Electron Builder <a href="https://www.electron.build/">here</a>).</p><h4>Step 4 — Configuring Next.JS</h4><p>Since we’re using Next.JS as the starting point, we should have a next.config.js file in the root of our project. In this file, we need to set the output mode to export, and disable the image optimization. So, inside this file, add the following params to the exported nextConfig object.</p><pre>const nextConfig = {<br>  ...<br>  output: &quot;export&quot;,<br>  images: {<br>    unoptimized: true<br>  }<br>  ...<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*wTWOJlGLPLEEBMJtLMFdvQ.png" /></figure><h4>Step 5 — Electron bootstrap</h4><p>Now, we will code the Electron part of our application. Start creating a folder called main, and two files inside that folder: main.js (as we set on the main key of our package.json) and preload.js (for exposing Electron to front-end), and insert the following content in the main.js file.</p><pre>const { app, BrowserWindow } = require(&quot;electron&quot;);<br>const serve = require(&quot;electron-serve&quot;);<br>const path = require(&quot;path&quot;);<br><br>const appServe = app.isPackaged ? serve({<br>  directory: path.join(__dirname, &quot;../out&quot;)<br>}) : null;<br><br>const createWindow = () =&gt; {<br>  const win = new BrowserWindow({<br>    width: 800,<br>    height: 600,<br>    webPreferences: {<br>      preload: path.join(__dirname, &quot;preload.js&quot;)<br>    }<br>  });<br><br>  if (app.isPackaged) {<br>    appServe(win).then(() =&gt; {<br>      win.loadURL(&quot;app://-&quot;);<br>    });<br>  } else {<br>    win.loadURL(&quot;http://localhost:3000&quot;);<br>    win.webContents.openDevTools();<br>    win.webContents.on(&quot;did-fail-load&quot;, (e, code, desc) =&gt; {<br>      win.webContents.reloadIgnoringCache();<br>    });<br>  }<br>}<br><br>app.on(&quot;ready&quot;, () =&gt; {<br>    createWindow();<br>});<br><br>app.on(&quot;window-all-closed&quot;, () =&gt; {<br>    if(process.platform !== &quot;darwin&quot;){<br>        app.quit();<br>    }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*0a-fdPQxaL59EC4c1ji0Jw.png" /></figure><p>As we can analyse, this code will use electron-serve to properly serve static files from the out/ folder, but only when our app is packaged (builded, in production, compiled, whatever you want). While not packaged, we will run our app through the http://localhost:3000 URL, which is the default URL for Next.JS projects. Also, we already prepared the script to load our preload.js file. Another point of this scripts is the &quot;did-fail-load&quot; event while development. We added it because sometimes Electron may start faster than Next.JS (remember they are called together with concurrently), so, in those moments, it will trigger an error that &quot;URL cannot be loaded&quot; or someting like that, and will give us only a blank screen. With this event implemented on our script, when this occurs, it will automatically reload the app content, until success when showing Next.JS content.</p><h4>Step 6 — Setting up the preload script</h4><p>Now, we just need to expose the Electron for the React/Next.JS part of our application. It’s very useful for using IPC messages, for example.</p><p>Inside the main/preload.js file we created before, insert the following content:</p><pre>const { contextBridge, ipcRenderer } = require(&quot;electron&quot;);<br><br>contextBridge.exposeInMainWorld(&quot;electronAPI&quot;, {<br>    on: (channel, callback) =&gt; {<br>        ipcRenderer.on(channel, callback);<br>    },<br>    send: (channel, args) =&gt; {<br>        ipcRenderer.send(channel, args);<br>    }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2FQfsXHdnprXQUdNCqqyzA.png" /></figure><p>This way, we can call window.electronAPI.on on Next.JS components to handle IPC data that comes from the &quot;back-end&quot; of our application, and window.electronAPI.send to send data to the &quot;back-end&quot; of our application.</p><h4>Step 7 — Testing</h4><p>Finally, we can just run npm run dev on our terminal. If all things are well configured, we should see a beautiful Electron window with the starter content of Next.JS. Also, the built-in DevTools shoud appear. And, in the running terminal, we can see the debug from both Next and Electron, tagged with different colors too. Now is time to develop our application. Remember that we have hot reload for front-end (the renderer/Next part of our app), but, when making changes into the &quot;back-end&quot; (the main/Electron part of our application) we need to stop the whole application (a simple Ctrl+C on the terminal do the job) then run it again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*UFjN4Skw98uNucU3x1WUdw.png" /></figure><h4>Step 8 — Building the executables</h4><p>Now it’s time to build our application executables. We’re using electron-builder to handle that for us. Start creating a file called electron-builder.yaml on the root of our project. Then, inside this file, put the configuration for building the application, according to the <a href="https://www.electron.build/">official electron-builder documentation</a>. You can find an example below:</p><pre>appId: &quot;io.github.rbfraphael.electron-next&quot;<br>productName: &quot;Electron Next.JS&quot;<br>copyright: &quot;Copyright (c) 2023 RBFraphael&quot;<br>win:<br>  target: [&quot;dir&quot;, &quot;portable&quot;, &quot;zip&quot;]<br>  icon: &quot;resources/icon.ico&quot;<br>linux:<br>  target: [&quot;dir&quot;, &quot;appimage&quot;, &quot;zip&quot;]<br>  icon: &quot;resources/icon.png&quot;<br>mac:<br>  target: [&quot;dir&quot;, &quot;dmg&quot;, &quot;zip&quot;]<br>  icon: &quot;resources/icon.icns&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MKX7UuCEJ8ZqyGoUKD8cHg.png" /></figure><p>After properly specifying the needed options on electron-builder.yaml file, you just need to run npm run build on your terminal. The Next.JS static files will be generated and exported to the out/ directory, then the Electron application will be compiled, and saved to the dist/ directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*y_ls_-5k_slT2zw5ua862Q.png" /></figure><p>Now, when you run your application with the exported files, you should see a Electron window with your Next.JS app, now without the built-in DevTools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*cGLkTPpNL5jcnYSyqgr1hw.png" /></figure><h3>Important Notes</h3><p>There’s some people having trouble with the routing inside the app. Some problems I haven’t found a solution to are related to the routing. First, using the App Router isn’t possible (technically is, but you’ll face some problems and bugs, mostly because the NextJS needs to <strong>export</strong> the statics — HTML, CSS and JS — instead of running NodeJS behind the scenes).</p><p>The approach of this guide is to use NextJS to the render part of your desktop application in Electron. Remember that Electron just “renders” a static webpage inside a native window on your computer, so expecting it to run back-end functionalities of NextJS (for example, using <em>getStaticProps</em>, or using App Router, or NextAuth, or <em>/api</em> routes directly from NextJS) isn’t possible, because you need to export your statics, instead of running a NodeJS runtime behind your app. If you need to do some back-end tasks, try to execute them on the main process of Electron, instead delegating them to NextJS. Also, when possible, pass arguments through your routes and do API requests directly from frontend (for example, using the <em>useEffect</em> React hook) to populate your views.</p><h4>But…</h4><p><strong>BUT</strong>, maybe there’s a solution for those problems. NextJS has a possibility to use custom servers (as described <a href="https://nextjs.org/docs/pages/building-your-application/configuring/custom-server">here</a>, on official documentation), but it may be more difficult to integrate with Electron in a good way, and also it will make your app more heavy, since it will truly serve your application (it will run a NodeJS server behind the scenes) on your end-user computer, in addition to enable your users to explore your front-end outside your desktop app (for example, NextJS will run on <em>localhost:3000</em> and your Electron will render that URL on the <em>BrowserWindow</em>, but it allows your users to open a browser — Chrome, Firefox, Edge etc — and access <em>localhost:3000</em> directly).</p><p>I haven’t tried this approach yet, but, surely, I will give it a try, and, of couse, I will update this article with the results of my experience.</p><h3>Conclusion</h3><p>Using Next.JS to build desktop application with Electron is a good idea, specially when you want to use React alongside with Next.JS features, such as easy routing. And it shouldn’t be a pain, and using Nextron it could be. So, the best approach (I personally believe) is to start from scratch. In this guide we learned an approach to handle that.</p><p>Hope this guide may help somebody :)</p><p>Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01bbf1fdd72e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>