12 ms·
NativePHP: A framework for building desktop apps using PHP
- joeldo 3y agoSo it ships Electron and a PHP runtime - What else can we include?
- skydhash 3y agoApache A k8s implementation
- rezonant 3y agolarge language model
- frfl 3y agojvm too, so we can write once run anywhere
- ceejayoz 3y agoIt ships with two web servers, per the Security page.
- bouncycastle 3y agok10k (aka the "kitchen sink")
- deleted 3y ago[deleted]
- jslaby 3y agoWordpress
- jamil7 3y agoDon’t give them any ideas.
- dashesyan 3y agoShould be called ElectronPHP
- Culonavirus 3y agoPretty much. Why would I use this instead of vanilla Electron?
- hparadiz 3y agoIt bundles the PHP run time for you.
- Gigachad 3y agoHow awful.
- dopidopHN 3y agoMeh. Compared to electron itself it’s probably not much. But calling it native is kinda weird.
- lelanthran 3y agoI like PHP, bit even I have to ask... Why not just use JS that comes with electron rather than bundling a third party language?
- eclipxe 3y agoBecause of Laravel and Livewire.
- pengaru 3y agophoton
- userbinator 3y agoPHPoton
- freedomben 3y agoYour 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.
- theteapot 3y agoSome people with coding experience just like PHP.
- jahsome 3y agoI have pushed production apps in php, go, .net, java, and j/ts. Touched some Django and Rails along the way. For fun I have played with elixir and more I can't think of at the moment. I'm personally never as productive and happy as when Laravel happens to be the right tool.
- rafark 3y agoExactly. I’ve been writing JavaScript as long as I have been writing php and I prefer PHP by a lot.
- eclipxe 3y agoLaravel is an incredibly productive framework and being able to build desktop apps with Laravel is a dream!
- freedomben 3y agoI agree Laravel is a great framework. I use elixir Phoenix as well (similar philosophy). But that doesn't seem like a good model for a desktop app, especially when there are tools like electron where you could build a SPA. The whole route based model makes a lot of sense for web, but on a desktop?
- smashed 3y agoWhat 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 https://en.m.wikipedia.org/wiki/PHP-GTK
- Gigachad 3y agoIs GTK native? Isn't it just another library out of many you can utilize? Is it any more native than QT or wxwidgets?
- simlan 3y agoFor Windows and Mac OS native is clearly defined by the OS libraries that arenpvoded by the company. For Linux to look very native you need to define the desktop environment. For stock Debian and Gnome desktop GTK bindings will look native. For OpenSuse with KDE QT will look more native.
- smashed 3y agoImho, in the context of a GUI library, native would mean it has the native look and feel of the platform and the performance. This usually means the app is written in exactly the same language/framework/libraries as the built-in, pre-installed core apps. Nowadays, users don't seem to care all that much though, and will tolerate a lot of crap and bloated apps, as long as it gets the job done.
- anonzzzies 3y agoEspecially, shiny UI (which I hear many of my colleagues mix with UX) seems more important than anything for many; performance, latency/snappy-ness, memory use, cpu use, battery consumption etc. I can present a high performance, native, tiny binary product with excellent UX but shite UI and a slow, heavy, battery sucking product with horrible UX but great UI and most will pick the latter. Now it's much easier to make that bloated shiny product, as you don't have to think about UX, performance, latency, memory leaks etc; you just stomp something together quickly, wrap Electron and ship. People who carefully weigh all the options and spend time making something great, generally don't get paid for their efforts. So why would they?
- omgmajk 3y agoHonestly 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.
- 39 3y agoTotally agree, modern PHP is quite fun.
- PlutoIsAPlanet 3y agoI kinda hope PHP would adopt java-like types for strings etc, to somewhat clean up the mess of its functions, e.g for strings - instead of str_contains, strtr, substr_compare you can do $myString->contains("test"); https://github.com/nikic/scalar_objects https://github.com/nikic/scalar_objects provides it as a plugin, but its not fully fleshed out.
- krick 3y agoPHP in 2023 is a great language, I always scoff when somebody tries to imply that Python or JS are "clearly superior" languages to PHP (which, to me, is a clear sign of illiteracy). But I am also kind of "the right tool for the job" proponent. Now is PHP the right tool to build Desktop Apps? - It is cumbersome to distribute. Rarely people have PHP installed outside of a docker container, and given quite short development lifecycle chances are their version of PHP is already outdated. - Concurrency support in PHP is still very poor. That seems quite a big deal for a desktop app. - NativePHP is anything but native. It relies on Electron, which is somewhat questionable on its own (even though very common nowadays). - …And, since it pretty much is just Electron, why do I need a Laravel app underneath anyway?! If there is a job for JS, it's exactly programming UIs (primarily because there are millions of UIs and thousands UI-targeted libraries written in JS by now) So, I am very skeptical.
- adamnemecek 3y ago[flagged]
- retrocryptid 3y agoStop it before it gets to the children.
- skyzyx 3y ago[flagged]
- splatzone 3y agoNice! 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-php/ https://benramsey.com/blog/2009/10/building-titanium-with-ph... Glad to see the PHP desktop app dream has been kept alive :)
- mattkenefick 3y agoShame that project went the way that it did. A bit ahead of its time if you ask me. There were a lot of controls that phones just didn't support well enough which complicated the project. It was more of a Cordova or Haxe than an Electron though. Unbelievably, Haxe is still actively maintained. I keep saying I'll get into it, but I never do.
- splatzone 3y agoThanks for sharing. Can you help me understand the difference between Cordova/Haxe and Electron? I mostly do web dev.
- p4bl0 3y agoIn 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.
- lawgimenez 3y agoNative is such an overused word. Lately I have to argue with clients what’s really native or not.
- dopidopHN 3y agoYah, and in this particular case it’s not. Bummer. Quick and dirty desktop app in php might be something interesting
- djbusby 3y agoGenPop thinks native means an app one can download and run, with tight integration with OS services. Not things like native WM, or os supplied libs/tooling. Native describes the user-feeling, not the developer-technology-analysis.
- oli-g 3y agoIf I can download and install Discord on my PC, I would describe it as a "desktop app". We have the desktop, we have mobile, and we have the web. The word "native" shouldn't even be in a user's vocabulary. And I believe it wasn't until Electron polluted the world with inefficient wrappers around a Chrome tab with a custom icon slapped on top. Once we were living that nightmare, developers of apps aimed at power users, who actually bothered to create a good experience, started differentiating themselves by offering "native apps", as in, "we actually coded an app for your OS". And as the time went by, the Electron web app resellers adopted the term as well.
- dolni 3y agoDoes 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.
- tambourine_man 3y ago> NativePHP is taking the world by storm… I like PHP, but this made me chuckle.
- LinguaBrowse 3y agoThe 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.
- Fire-Dragon-DoL 3y agoElectron is native. If you use windows APi or appkit, you are writing assembly code. /s
- deaddodo 3y agoYeah, super disingenuous. Especially considering PHP is already native (unless you mean specifically compiled code). It also has direct bindings to GTK: http://gtk.php.net/ http://gtk.php.net/ And other native libraries. This project seems to conflate "native" with "has its own window" (versus running in a browser). While I would argue the more common understanding is "native" meaning "running outside of a sandbox/closed environment and directly on the OS". Ironically, using the latter definition, this project is less native than just coding PHP directly.
- biugbkifcjk 3y agoWhen they said native, they actually just meant local.
- deaddodo 3y agoNo, they didn't. Unless you can Explain how: ./Electron.app Is any more local than: php ./MyApp.phar Especially considering the former spins up an entire browser + PHP server instance, while the latter runs the code directly.
- johannes1234321 3y agoWhat is more "native" about the former?
- aetherspawn 3y agoAre there any screenshots anywhere to understand what kind of app this is for?
- Gigachad 3y agoBuilding native apps when you learned to program in 2005 and refuse to learn anything new.
- ptx 3y agotheForger's Win32 API Programming Tutorial [1] was available in 2001 according to archive.org, showing how to build actual native applications without anything even remotely new. [1] http://www.winprog.org/tutorial/simple_window.html http://www.winprog.org/tutorial/simple_window.html
- rvz 3y agoThere is nothing 'native' about this at all. Just a PHP library on top of Electron against the claim of "truly native" apps.
- whalesalad 3y ago[flagged]
- mattl 3y agoPHP code is very easy for an end user to deploy. WordPress is something that’s pretty easy for beginners to set up on a server using an SFTP client.
- iambateman 3y agoSo, 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.
- krapp 3y agoAlas. If only it were possible to host a Laravel app on the internet.
- eclipxe 3y agoThere are often times you want something that runs offline easily or can be distributed per-user without dealing with multi tenancy, etc.
- krapp 3y agoSure, but packaging a web app with a PHP framework in a Chromium wrapper to accomplish that is still ridiculous. I don't care how ubiquitous the whole "web apps are now native apps" paradigm becomes, it will never not be ridiculous.
- meatjuice 3y agowhy php though?
- Hrundi 3y agoMany people enjoy working with it, it's perfectly fine for almost everything and it's fast enough? I mean, why not? Other apps bundle entire runtimes for other languages, I don't see how PHP would be any different
- dceddia 3y agoI 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.
- colecut 3y agoThanks for this interesting info.. Also, Recut looks very nice. Do you mind if I ask what the full tech stack is for a video-editing app like that?
- dceddia 3y agoThanks! It's Svelte, TypeScript, WebGL (for the timeline) and Tailwind on the UI side, and Rust for the backend that calls out to the libav libraries for the audio/video encoding/decoding. And there's a little Swift in there for some native Mac stuff.
- djbusby 3y agoWhere is it slow? I'm assuming libav/libffmpeg stuff - or maybe just in IO cause videos are fat.
- dceddia 3y agoThat's one place for sure, yeah. Video decoding is just resource intensive, especially if it's being done in software. Switching to hardware decoding is a big thing that's still on my todo list. Beyond that, drawing the timeline efficiently took some work. I spent a bunch of time rewriting it to use WebGL recently, and before that it was some 2D canvas stuff. Plain old DOM elements slow to a crawl when there's 10k+ of them :D Another little wrinkle is that calling between JS and Rust has a fair bit of overhead, so I try to minimize that and avoid sending lots of data back and forth. I think Tauri v2 is supposed to improve that a lot, but right now it's basically serializing everything to JSON and back. There's an alternative where you can send raw binary back and forth, and I'm using that in some spots. (re: the sibling comment about browser compatibility, I've got some fallbacks in place because old Safari didn't support it, heh)
- quasarj 3y agoWhy do people keep trying to resurrect PHP?
- gomoboo 3y agoResurrect? PHP never died. It’s still going strong today with frameworks like Laravel.
- artificialLimbs 3y agoI guess because we keep cashing fat checks with it?
- tjpnz 3y agodang 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.
- efitz 3y agoSpeaking as a security professional, for the love of God, why?
- jacquesm 3y ago(1) because they could (2) because it runs on top of electron so it is mostly a local affair (3) because some people might want to build a desktop app but don't have overlapping skills with desktop programming languages I don't see why they shouldn't be doing this. But, since you are a security professional, please point out why this is more or less secure than anything else built on top of electron?
- efitz 3y agoPHP is notoriously insecure. https://www.cvedetails.com/vulnerability-list/vendor_id-74/product_id-128/PHP-PHP.html https://www.cvedetails.com/vulnerability-list/vendor_id-74/p... Just because it runs on a desktop doesn’t mean that it won’t be exposed to malicious code.
- AndroTux 3y agoI’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?
- holoduke 3y agoSeen plenty of nice nodejs backends. Seen also some serious frankenstein PHP projects. Language really doesnt matter. The people behind it do.
- Kovah 3y agoI would say that the truth lies somewhere in the middle. Of course, people behind projects matter a lot. You can have robust and beautifully crafted PHP projects, and also horribly running, bloated and hacky Rust or Java projects. But, AndroTux has an absolutely valid point with saying that PHP was designed to run websites. Most languages have a clear focus of what they should and can do. There's the neat quote "your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should" and it pretty much sums up the matter. Some languages should stay with what they are made for.
- AndroTux 3y agoWell said. I don't necessarily think that PHP can and should only do HTML rendering. Laravel for example includes a nice job queue which in my opinion makes perfect sense, as it is tightly integrated with the rest of the system, even if it's technically not what PHP was designed to do. But if you have to ship the interpreter and an entire browser just to make it work, maybe it's time to consider other options. And yes, that applies to JavaScript Electron apps as well. I can see the value in them from a business standpoint, but the amount of wasted PC resources just bugs me a lot. I don't want to waste 1 GB of memory just for a chat client.
- ulrischa 3y agoGreat. PHP became a very good programming language. Sadly it has to fight with a bad reputation from its past.
- hahamaster 3y ago$NativePHP: A $framework for $building $desktop $apps $using PHP
- exikyut 3y agoUncaught error: Undefined constant "A" Uncaught error: Undefined constant "for" Uncaught error: Undefined constant "PHP"
- paulvandermeijs 3y agoI'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.
- JodieBenitez 3y agoSomehow related, I've been using pywebview for some internal tools: https://github.com/r0x0r/pywebview 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.
- karencarits 3y agoI 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 https://github.com/cztomczak/phpdesktop
- deleted 3y ago[deleted]
- penlightment 3y agoEveryone is focusing on the fact that `native` is not applicable to the current implementation. I think if done right, It can come quite handy