Developing a PHP SDK

Hi,
I’m just starting my journey into smart contracts and dapps and I have to say that I fell in love with Cadence and how you organized things in general.

I’m trying to build something with NFT that would require also some back-end work in PHP that ideally should communicate directly with the Flow API.

I’m struggling to decide whether to move all my back-end code to nodejs to use your JS SDK, or if I should try and build a PHP SDK that could be reused by other people and for future projects too.

Do you know if there is someone else already working on it?
Do you think there would be a real benefit in making one or should I just stick with the official JS one for now?

I saw this blog post suggesting on how to use the SDK with Ruby, so I was considering to take a similar approach.

Do you think I should be able to achieve this relatively easily or am I getting into a rabbit hole and I’d better spend the time writing my dapp with JS?

I know PHP is not as cool as Go, but it still powers a huge portion of the websites in the world, so I think there could be some good potentials there.
Anyone interested in teaming up to work on this maybe?

Thanks so much and keep up the awesome job you’ve been doing!

1 Like

The same question, is Python or Java also possible? :joy:

now… Java is online :joy:

cool

1 Like

Hi @luca,

I love Cadence too.

I think PHP is a great language for building your app.

PHP doesn’t yet have an official library, but I encourage you to build one. If you will start building a library for interacting with flow blockchain be sure to check out Flow Protocol Buffer Source Files here: flow/protobuf at master · onflow/flow · GitHub you can help yourself with this library GitHub - drslump/Protobuf-PHP: PHP implementation of Google's Protocol Buffers with a protoc plugin compiler to implement protobufs.

Let me know if you need any help.

2 Likes

Thanks @sideninja ,

I was also thinking to use the Flow CLI as a quick workaround for the moment.

I’m so excited that I want to get my first dapp out there ASAP :slight_smile:

But after that I think I might start working on it, especially if there are more people interested in it, because I’m planning to create a couple more dapps that will need PHP as well.

I’ll write here in case I’ll start coding it, so that you can track the progress.

Hello @sideninja , I have implemented the Python version of Protobufs and submitted the request. I would like to ask if the Flow - Python-SDK has been officially implemented? If I want to join, can I find someone to cooperate with? Thank you

@luca Great, keep me updated on how that goes. I’m helping to develop CLI and I would love any feedback you will have. What are you building if it’s not a secret? :slight_smile:

@Lsy No, the Python-SDK is not officially supported and would be awesome if you start building one. I think that PR should be better placed in this new repo with python-sdk. I can help you with any questions you might have when implementing. Let me know.

1 Like

Thanks @sideninja !

I’ve built something similar for ffmpeg that uses also a CLI and I think it could be worth exploring it, especially since you are developing and improving it.

It might not be the ideal solution on the long term maybe, but definitely something that could be put out there for everyone much quicker.

I have two projects in mind but I’d rather DM them to you in Discord to keep them “secret” for a little bit longer :slight_smile:
My handle is “lucamayven” in Discord so please feel free to DM me any time.

Thanks!

Cool :slight_smile:
What do you mean by something similar?

Oh, that’s great to hear, Nah I won’t snoop too much around as long as you want to keep it secret but definitely share when you will feel comfortable and if you will need more help let me know.

Basically the idea is that I would offer methods with various parameters to interact with Flow but then underneath the curtains I would just translate everything into a single command that I can execute with the CLI, so that I would avoid going through the Protobuff part.

What I had in mind is that in PHP you could write something like this

$flow = new Flow(‘0x235732897’,‘private_key_here’);
$results = $flow->transaction(‘transaction code here or reference to a saved file’)->gasLimit(100)->sign()->submit();

And underneath the curtain I would just translate all this into a flow command like this

flow transactions send
–code MyTransaction.cdc
–signer my-testnet-account
–host access.testnet.nodes.onflow.org:9000

The good part is that it would be really easy to write and to get it out for everyone to use pretty quickly, and it wouldn’t have any other requirements beside having the Flow CLI installed.

The bad part is that it would be limited to offer the functionalities that the Flow CLI offers and in certain cases maybe parsing the results returned from the CLI might not always be reliable if changes are made along the way.

So I was thinking that we could start with this simple solution suing the CLI for now and then (after I have my dapps on production) I could take a look at the Protobuff version too.

Please let me know if what I have in mind is actually doable, or if you suggest that I should concentrate on the Protobuff version only.

Thanks!

Ohh, I see. I think this can be a quick dirty solution for sure (if you need something today), but like you said down the line should be converted to directly implementing protobuffs.
Protobuffs are not hard to implement at all, you can check here: protobuf/php at master · protocolbuffers/protobuf · GitHub

And I totally forgot to mention to @Lsy that you should totally check our Discord where you also have a channel for python-sdk. @luca you might also benefit from joining Discord if you haven’t done so.

@Lsy I’ve spoken too fast. One of my colleagues @TheOneSock is making the flow python-sdk library here: GitHub - janezpodhostnik/flow-py-sdk: Unofficial flow blockchain python sdk

Maybe you can even help there.

Thats right! Im trying to put something together. I have sending scripts and transactions covered, just want to make things nicer to use and document everything, before considering it ready for real use…

… but we already spoke on discord @Lsy :slight_smile:. Your interest is much appreciated! Since we last spoke I added a brief TODO list of the areas I want to improve. Any input is very helpful.

2 Likes

@sideninja I decided after all to go ahead and implement the SDK properly with the Protobuf! The other solution was quick but too “dirty” eheh :slight_smile:

I just created a Git repo here that I will keep developing in the coming days.

My handle in Discord is “lucamayven”. Could you please create a “flow-php” channel so that maybe I can connect with other developers interested in the project?

Thanks a lot!

1 Like