33
linuxxx
4y

Currently trying to convert a python application to PHP because the learning curve of python is a little too high right now for me.

It's especially a challenge to find PHP functions/libraries which can do the same as some python ones.

I've never written a single thing in python, this is a very weird experience!

Comments
  • 32
    😏

    <?php

    exec('python /location/to/python-script.py');

    echo 'Job done!';

    ?>
  • 4
    I tried to rewrite a go based program in c#.

    That was a similar solution as go has a lot of multi thread support that lacks equivalents in .net and c#.

    So I do understand the pain.

    Or trying to fix bugs in an old perl script. (I don’t know perl either)
  • 0
    @incognito I know I know but I want to keep it as native as possible and the python application is a web listener ;)
  • 4
    @incognito Okay nevermind, this is starting to look like an actually good option .____.
  • 1
    @linuxxx nah, I know you can do this 😉

    Have a little faith in yourself 💜
  • 0
    @linuxxx What about Swig? Can that help? It’s not pretty but it’ll give you something to work with?

    Full disclosure: my only experience with Swig is watching it do stuff in a Docker build (by which I mean convert a C++ library to PHP)
  • 1
    @incognito Oh this isn't much about my skillset, I'm just entirely unfamiliar with this topic so it'll be a while until I learn enough to natively convert this I fear :)
  • 1
    @incognito I wonder how would this work when we host it
  • 1
    @Voxera I know it's not related to this rant but can you look at my last post (question), maybe you can help me. Please 🙏
  • 1
    @incognito The native conversion is actually going way better than I thought!
  • 0
    Pray you don't need some library the python code uses that is only available in python. I ran into that problem going from python to C++. lxml and Construct are both awesome libraries. Have not found replacements that are as simple and good.
  • 0
    @Demolishun I don't think so yet but I'm stuck somehwere now where I simply have no clue as for how to convert that to PHP because I'm not even sure what it does in python...
  • 2
    @linuxxx shell_exec()

    You get all the output from the python script in case you need to parse it.
  • 0
    @Evonox7 if it the one about moching in go I am sorry, while I can read and mostly understand go code I have never written any.

    I have tried to port the raft server example from go to c# but gave up and wrote it from scratch as there was so many threading issues that just cannot easily be dine in c#.
  • 0
    @Voxera Cool, thanks.
  • 1
    Dude you can so learn Python in a sitdown if you want to. You're a smart dude.

    I am assuming the application is not necessarily web related?
  • 0
    Or you could just keep it in Python and code as you're used to?
    Did you see/try/discard https://github.com/juokaz/pyhp
Add Comment