Question regarding backend software

I’m a fullstack developer excited to jump on the Web 3.0 bandwagon while it’s still early.
But I have one question: is it possible to run PHP apps on the IPFS protocol?
Or is it really just frontend only?

And if it’s possible to run PHP apps, how would I secure files others shouldn’t be able to read, like configuration files with database passwords in them?
And where does the database get run from, now that the middleman (aka, server) gets cut out?

Please remain nice, if it’s impossible, I’m still willing to figure out some workaround (like exporting static versions for use on IPFS for example).

The problem of PHP is that it would need to run in the user machine.

When building web apps you have 2 sides :

  • The code that run on the user computer (client)
    For example javascript in their browser, their IPFS node, …
  • And the code that run on your own computers (servers)
    For example a PHP + mysql server.
    I guess you already knew that.

What web 3.0 is about, is removing the second category, you now only have the first, the code running the client (and also making this code opensource and reviewing it so users trust this code).
Actually it’s not really removing servers, you still have other computers, you just don’t trust them, whatever they do is seen as wrong unless proven otherwise.
So whatever your protocol does must be checked by the client, ideally all the way your server could cheat must be fixed in the client.

There are many ways to fix this, one example is for everyone to run everything, so if an other computer do a calculation other one need to know about (example moving money from an account to an other), instead of sending the result authoritarly, you send cryptographical proof from the sender account and everyone checks it and moves funds accordingly on their side, and everyone keep track of the current state and change it accordingly.
This is how blockchain works for example.

In reality it’s unlikely that you will start from nothing, you have a bunch of code and networks ready to use that will make your life easier. For example if you need a server and a database, instead of rewriting a blockchain yourself, you could just use ethereum.

So you could write a web 3.0 app on PHP, but that would be almost nothing like you know currently, you would need each user to run their own node, running PHP code to check that other nodes aren’t doing bad.
You could also go for a half centralised network like fediverse, have a bunch of user accessing a centralised node, however the nodes themself are running a decentralised network and you could just spin up your node to join it.

The reality is that the most decentralization is done when all users run their own node and trust no one.
And there are really good tooling to go about that.

  • Have a backend written in solidity or vyper and deployed on the ethereum blockchain (so everyone can see and check what is happenning).
  • And a client displaying informations in a nice way to the users, this could be anything that a user run in it’s computer but the reality of it is, JS is very likely the best for that, everyone has a browser, the simplest way to connect to web3 is through your browser, so why would you use something else ?

That why most dapps are built using:

  • solidity for backend
  • js with web3 + html + what other crap a browser need to make that pretty for the client

Then IPFS to distribute the js and html.
As this is a really strong base that will save you many months of your life building something new, and many years for people to start trusting it.

My main point is that if you are doing PHP your way to move money from an account to an other would likely be something like updating 2 rows in a database, one adding, one subbing.

In dapps this is not possible as this require trusting a central server, in a dapp you need everyone to be capable to authenticate the transaction, everyone to check if the funds were there, … for everyone to a true proof that the transaction has happend, not trusting any central server (btw if they trust multiple server it’s still an issue, the issue is trusting someone else, not servers).

Yeah, I was already afraid of that.
I run many kinds of apps, it’s not really a problem for a blog (probably even the comments section wouldn’t really be a loss, since even right now no account, username, or email address is required).
Things like PeerTube and Pleroma on the other hand, that’s probably not going to work…

I’ve seen something like Orbit DB as a replacement to SQL for IPFS, so there’s that at least.
My biggest reason to stick to PHP is because of its superior performance and stability over Node because PHP code doesn’t eat up 64 GB of RAM on the client side when there’s no need to, but can’t expect everyone to have PHP installed on their machines, let alone the same version.

As for the transaction part, I don’t have intentions to do anything money related, simply want to make whatever I already have running on IPFS.
Most apps can be simply rewritten to JS (or Golang) for use on IPFS.
Some apps will require an alternative strategy though.