A
A
Alexander Saneev2017-05-26 23:45:44
PHP
Alexander Saneev, 2017-05-26 23:45:44

How to execute Go code in PHP?

Is it possible to "cross" Go with PHP?
What would the main code be in PHP, and rewrite some of its parts in Go. (such as uploading files to the server, working with the database, and maybe something else)
How can this be done? (if possible)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Aksentiev, 2017-05-27
@Sanasol

such as uploading files to the server, working with the database, and maybe something else

And in php, only echo will remain visible?
if you can’t do it normally on php, is it worth trying on GO?
Either do everything on go, or hang heavy tasks on go, it will be a daemon or a worker for processing from the queue, well, php does not execute go or vice versa.
Uploading files and working with the database is not a difficult task, especially for php.
Processing files after uploading , yes, it can be heavy and long, but it is very rare: video, large data import / export.
Yes, but they are also solved in php, just a queue of tasks, and not during the execution of a request from the user.
In general, based on what is written: either you have shit code or you fantasized something that does not exist, and GO will not save you in any way until you figure out what exactly you need to do / fix.

R
Roman Mirilaczvili, 2017-05-27
@2ord

I don't know what the hard stuff is. Are they at least designed as background tasks for you? Heavy tasks are those that heavily use server resources (CPU, I/O, network) or take longer than the user would like to wait.
Heavy queries include pre/post-processing of any data, generation of reports for business analytics, i.e. operations that can be performed without the user waiting for a response.
Usually they are taken out to the queue handler (Gearman, Beanstalk, ZeroMQ, RabbitMQ, ...). And the queue worker can be written in any language, if, say, the MsgPack protocol is used. Tarantool with built-in Lua language can also be used, as well as Redis as queue data stores.
That is, this is a transition from a monolithic application to microservices.

S
Stalker_RED, 2017-05-27
@Stalker_RED

For example, configure nginx to process some of the addresses through php, and others through go.

F
Firues, 2017-06-05
@Firues

Write a microservice with a REST API. This is the only option that will work quickly and will do what you need.
nordicapis.com/writing-microservices-in-go is an example.
In php everything is accepted and parsed as json.
Please mark someone's answer as correct. ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question