Jump to content

Using python to build webapp


MasterOfFreedom

Recommended Posts

I am not a PHP dev, however, i am familiar with Python and would like to create my IPS application out of python.  Does anyone have any experience in doing this, some tips? Is there a standard way to couple PHP and Python? I know i can use exec and call a script file, but the core application is going to be pretty complex.

What im doing is uploading a file and parsing the information inside to display in a post.  Most of these files are compressed and have to be decompressed and bit shifted before it can be read.  Then i get the info and place in a database with additional information coming from IPS such as post author etc...  I don't want a hackish solution.  If i could use PHP for the front end to work with the IPS api and then use python for the backend, this would really make my world a lot easier.  Am i just asking for trouble? lol

Link to comment
Share on other sites

IPS apps are written in PHP. I have suggested that IPS implement the next version by separating front end and backend (so the front end PHP used a REST API to invoke the backend), but Matt shot it down as too much work for too little benefit. I'd like the backend API to be implemented in Go using micro-services for unlimited scaling and high availability, but this is just not going to happen.

Link to comment
Share on other sites

The software is written in PHP, and I'm not aware of any way you can write something in python and just have it executed as PHP.

If you can muddle through just enough to get the "application" bits going within our software, you could absolutely pass off the rest of the execution (using exec() or system() or something along those lines) to your python script, but at that point you may be better off just porting your code to PHP anyways. We actually recommend admins disable the exec() function for instance, since we don't use it and it can constitute a security concern in some environments.

Long story short - your best bet is to just do this in PHP entirely. If that isn't feasible, you will at least need to create a "wrapper" in PHP that can pass off execution to your python script, and then handle the response and display it to the user.

Link to comment
Share on other sites

9 minutes ago, bfarber said:

The software is written in PHP, and I'm not aware of any way you can write something in python and just have it executed as PHP.

If you can muddle through just enough to get the "application" bits going within our software, you could absolutely pass off the rest of the execution (using exec() or system() or something along those lines) to your python script, but at that point you may be better off just porting your code to PHP anyways. We actually recommend admins disable the exec() function for instance, since we don't use it and it can constitute a security concern in some environments.

Long story short - your best bet is to just do this in PHP entirely. If that isn't feasible, you will at least need to create a "wrapper" in PHP that can pass off execution to your python script, and then handle the response and display it to the user.

Right, agree with you on every point.  Exec was the hackish solution i don't want as it opens up security issues.  I was trying to think of a way to play with Django and a Restful api to pass the information back and forth.  Python is just so nice! I just didn't know if PHP had a module to communicate with Python in an interop fashion.  I saw some old projects from back in 2002 but never seemed to take flight as a full module.

 

Is there any PHP modules someone would recommend for dealing with database etc? or does Zend do all that? Looks like i have a lot of PHP learning to do...

 

Thanks, guys.

Link to comment
Share on other sites

PHP has database support, yes. Our software relies on it, so the necessary modules will always be present. To access the database, you would use our database driver class.

$iterator = \IPS\Db::i()->select( '*', 'core_members', array( 'member_id=?', 1 ) )->first();

https://invisioncommunity.com/developers/docs/fundamentals/accessing-the-database-r166/

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...