Building Desktop Applications with NativePHP and Laravel

Building Desktop Applications with NativePHP and Laravel

Laravel, PHP

NativePHP, created by Marcel Pociot at BeyondCode, allows Laravel Devs to leverage all the working knowledge we already have with Laravel to build native Linux and MacOS applications.

However, NativePHP was created to enable the rapid creation of Laravel-based projects. It is not currently a standalone PHP framework for creating desktop applications or websites.

NativePHP is currently in alpha and not yet ready for production use.

What is NativePHP?

NativePHP offers the flexibility to select between two widely adopted technologies, namely Electron and Tauri, as the foundation for your application. Both Electron and Tauri enable the development of cross-platform desktop applications using JavaScript, HTML, and CSS. This combination of web technologies to create a “native” application can be perceived as a remarkable feat. NativePHP simplifies the process by providing a user-friendly API that aligns with the familiar Laravel framework, facilitating the development of applications using either of these underlying technologies. In this instance, I will be showcasing the utilization of the Electron wrapper.

And you know what? PHP is far from being dead. It’s thriving, all thanks to remarkable frameworks like NativePHP. So, let’s delve into the fascinating world of building a desktop application with NativePHP on Laravel.

Prerequisites of NativePHP configuration

Prerequisites of NativePHP configuration

Let’s dive into the exciting steps ahead.

Steps to develop NativePHP app

Steps to develop NativePHP app

Step 1: Create a New Laravel Application

Are you ready to start on an amazing journey? The first step is to create a brand new Laravel application! This open-source PHP framework is the perfect toolkit for developers who want to build stunning web applications with ease. With its simple and elegant design, Laravel is the go-to choice for those who demand nothing but the best.

Creating a Laravel application is a breeze thanks to Composer. All you need to do is run a simple command in your terminal! You’ll be on your way to building the web application of your dreams. So what are you waiting for? Let’s get started!

composer create-project laravel/laravel nativephp-itpath

This command facilitates the establishment of a new Laravel installation within the nativephp-itpath directory.

Step 2: Install NativePHP

Congratulations on creating your Laravel application! Now, let’s take it to the next level by transforming it into a native desktop application with the help of NativePHP. This powerful tool provides all the necessary dependencies and tools to make your web app shine on desktop screens.

But don’t worry, installing NativePHP is a breeze. All you need to do is require the package via Composer by running:

cd nativephp-itpath
> composer require nativephp/electron
> php artisan native:install

This command facilitates the installation of the nativephp/electron package into your Laravel application.

Step 3: Publish the NativePHP Configuration file

In certain instances, subsequent to the installation of a package in Laravel, it may become necessary to disseminate its configuration file within your application. This task can be accomplished by employing the vendor:publish command. In the event that the NativePHP configuration file fails to be published automatically, execute the subsequent command:

php artisan vendor:publish –tag=nativephp-config

The execution of this command facilitates the dissemination of the configuration files pertaining to the nativephp\electron package to the designated directory within your application’s configuration. Consequently, you are endowed with the ability to exercise authority over the configuration settings of your NativePHP package.

The configuration file, namely config/nativephp.php, is represented by the following code snippet.

Step 4: Serve Your Native Application

Finally, now that you have successfully set up the Laravel application and installed NativePHP, you are ready to serve your application and begin your development journey. Simply run the following command:

php artisan native:serve

NativePHP demo application

🎉 Congratulations! Your PHP desktop application is now up and running. I understand how much effort and dedication it takes to create something like this, so I am truly happy for you. Well done!


In recent years, PHP has seen a resurgence in importance and adaptability, thanks to frameworks like Laravel and innovations such as NativePHP. These developments have transformed PHP from primarily a web development language into a versatile tool for building robust desktop applications. Laravel and similar frameworks offer structured, efficient ways to create desktop applications with built-in functionalities.

NativePHP takes it a step further, enabling PHP developers to create native desktop applications that run directly on users’ machines. This approach provides cross-platform compatibility and leverages PHP’s capabilities, making it a compelling choice for desktop software development.

Posted on November 17, 2023 by Sagar Vaghela
Sagar Vaghela