NativePHP: A framework for building desktop apps using PHP

by brysonreeceon 7/21/2023, 10:06 PMwith 124 comments

by LinguaBrowseon 7/21/2023, 11:22 PM

The documentation says it builds “truly native” apps, so I was expecting direct PHP bindings to native APIs and for the UI to be fully native (AppKit, GTK, etc.). On closer inspection, though, it’s just a PHP framework on top of Electron? A bit disingenuous.

by smashedon 7/21/2023, 10:55 PM

What exactly is "native" about this?

I remember there was PHP bindings for GTK [0], which at least looked sort of native on Linux.

This could be cool if you can ship a large PHP backend codebase, allowing a web app to become an offline desktop app. You'd probably have to bundle a MySQL instance many cases though :)

0: https://en.m.wikipedia.org/wiki/PHP-GTK

by AndroTuxon 7/22/2023, 7:41 AM

I’m a huge PHP fan. But hell, no.

Why don’t we use tools for the things they are good at? PHP as a backend server language is great, because it was built for it. Just like JavaScript is intended for web frontend applications. In my opinion, nodeJS was a mistake. It’s built upon layers of workarounds, and NativePHP looks exactly the same, just the other way around.

It’s not that hard to learn another programming language once you’ve learned one, so why not learn to code in a language that’s designed for your task, instead of trying to frankenstein some monster just so you don’t have to learn a new language?

by dceddiaon 7/22/2023, 1:34 AM

I haven’t seen anyone talking about how this supports Tauri yet, so I’ll start: that’s pretty great!

For anyone who hasn’t heard of it yet, Tauri is a really nice Electron-like alternative that uses the system webview instead of shipping an entire copy of Chromium, and it’s written in Rust, so I’d presume there’ll be some way to call out to Rust from PHP.

I’m excited to see Tauri get more adoption. I’ve been building/selling a video editor with it for the past couple years and while it’s not always perfect, it suits my needs and I like that native performance is always an option when I need it. I’ve yet to run into a performance problem that is completely out of my control. Not to say my app is perfect, just that where it’s slow, it’s not JavaScript’s fault.

by splatzoneon 7/21/2023, 11:03 PM

Nice! I remember using a tool called Appcelerator Titanium about 15 years ago. It was like a precursor to Electron, and you could use various languages to build desktop and mobile apps - including PHP. It blew my mind at the time that this was possible.

https://benramsey.com/blog/2009/10/building-titanium-with-ph...

Glad to see the PHP desktop app dream has been kept alive :)

by freedombenon 7/21/2023, 10:53 PM

Your Scientists Were So Preoccupied With Whether Or Not They Could, They Didn’t Stop To Think If They Should.

On a serious note, this is absolutely badass. In the spirit of hacking, kudos!

The ideal market for this seems to be people with only PHP web app experience that need or want to build a "native" app, that otherwise wouldn't be able to do so with existing tools.

by lawgimenezon 7/21/2023, 11:10 PM

Native is such an overused word. Lately I have to argue with clients what’s really native or not.

by karencaritson 7/22/2023, 11:58 AM

I am a bit surprised by the critical tone in the comments here. Phpdesktop [1] is, for example, a very nice application, and the ability of php to just make some simple scripts on the go and have something that works, is wonderful (compared to js where you often have to build etc, the threshold of getting started on a new computer is high). I have several times needed to make simple applications with a database, and php is perfect for that usecase. Making it simpler to share these applications to non-technical users for offline use is nice

[1] https://github.com/cztomczak/phpdesktop

by omgmajkon 7/21/2023, 11:03 PM

Honestly excited about this, I am one of those people that really love PHP from the old days and I still use it from time to time to build small web apps and api's. I don't get the hate that PHP usually gets, I've always kinda liked it.

These days I mostly program in C, CAPL and Python but I would love to build apps in PHP.

by iambatemanon 7/22/2023, 12:52 AM

So, I’m incredibly enthusiastic about this.

It’s ok if you aren’t, but I am.

Development is easier when we keep more things the same. It saves energy for a Laravel developer to deploy to Mac using the same code, tools, and architectures as their web app. This won’t be true for all mac apps, but certainly will be for some.

Maybe NativePHP turns into a big deal and helps a lot of people deliver great experiences or maybe it doesn’t…but I’m grateful to the team for their effort pushing the boundaries.

by JodieBenitezon 7/22/2023, 11:50 AM

Somehow related, I've been using pywebview for some internal tools: https://github.com/r0x0r/pywebview

Probably not as full-featured as Electronjs, but since we have a bunch of python scripts to convert to desktop apps, it's very useful.

by tjpnzon 7/22/2023, 2:55 AM

dang can you update the title to reflect that this is a framework for building Electron apps in PHP? The name they've chosen is unfortunate and some are feeling misled.

by dashesyanon 7/21/2023, 10:42 PM

Should be called ElectronPHP

by tambourine_manon 7/22/2023, 4:15 AM

> NativePHP is taking the world by storm…

I like PHP, but this made me chuckle.

by ulrischaon 7/22/2023, 9:44 AM

Great. PHP became a very good programming language. Sadly it has to fight with a bad reputation from its past.

by p4bl0on 7/21/2023, 11:04 PM

In the same kind of spirit but for Python I recently discovered pywebview. It really is amazing how simple and fast these tools make developing little apps that can be run locally, without your users needing to manually launch a server or you worrying about the browser.

by aetherspawnon 7/21/2023, 11:50 PM

Are there any screenshots anywhere to understand what kind of app this is for?

by hahamasteron 7/22/2023, 10:37 AM

$NativePHP: A $framework for $building $desktop $apps $using PHP

by joeldoon 7/21/2023, 10:40 PM

So it ships Electron and a PHP runtime - What else can we include?

by penlightmenton 7/22/2023, 12:46 PM

Everyone is focusing on the fact that `native` is not applicable to the current implementation. I think if done right, It can come quite handy

by paulvandermeijson 7/22/2023, 11:45 AM

I'm a bit confused by the fact that all code samples in the docs are missing PHP tags.

I assume they're still required since leaving them out would probably mess up all editor and tooling support.

Despite the great improvements PHP has seen lately it will always be a template language for me as long as you have to write your code between those tags.

by rvzon 7/22/2023, 12:47 AM

There is nothing 'native' about this at all. Just a PHP library on top of Electron against the claim of "truly native" apps.

by meatjuiceon 7/22/2023, 12:55 AM

why php though?

by efitzon 7/22/2023, 5:30 AM

Speaking as a security professional, for the love of God, why?

by quasarjon 7/22/2023, 2:53 AM

Why do people keep trying to resurrect PHP?

by dolnion 7/21/2023, 11:14 PM

Does anybody think that something like this is useful except as an academic exercise? I can't get there.

There are many languages better suited to delivering native apps. The pitfalls of electron are already well understood. If you need electron ANYWAY, then you might as well just use electron.