-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Portability #54
Comments
Hi, the easiest way would be to use the I've opened a PR with relevant fixes on #55, but this needs some extra work for linking |
Hi @deuill Thanks for the help! After a bit of mucking around I got the Dockerfile to build a go-php.a file located in Apologies for my naivety but this is my first Go project. Now that I have the go-php.a file what do I do next? You mention "then build your project that uses go-php with the static tag.". I placed that go-php.a file at
Any ideas? |
I am looking at if there are any performance advantages to using gophp in aws lambda. I appreciate how to compile php statically and also how to use gophp to execute php. I have not had any success however compiling my gophp program into a static binary. I am missing a bit of cgo understanding i think. Any pointers? |
@richardjennings That is exactly what I am trying to do as well. I am currently launching php from node but looking at gophp to see if we can get extra performance. If you managed to crack it please let me know! |
This would be interesting if we could do this, especially in lambda! |
Apologies for the late reply, I've pushed some fixes to #55 which should allow building
Your best bet would be to build a Docker image with PHP built statically (with
Obviously not ideal, but I haven't been able to build a shared library (with |
I did have a go trying the example above after building a new docker image against your pull request but it wouldn't compile my code, something related to linker errors with curl. I'll be honest I'm terrible at these sort of things. I think it would be awesome if we could get the hello world example compiling statically and an example in the README. 💃 |
Those issues were fixed in recent commits to the branch, try pulling and re-compiling. |
I've literally just pulled that feature branch in #55 to try it. Is that the right branch? |
Correct, that's the branch. What error are you getting (I probably missed something)? |
I'm getting the following errors, also had to install
|
I'll be honest I have no experience with cgo at all, heres what I'm trying to compile :) package main
import (
"fmt"
php "github.com/deuill/go-php"
)
func main() {
engine, _ := php.New()
context, _ := engine.NewContext()
val, _ := context.Eval("return 'Hello World';")
fmt.Printf("%s", val.Interface())
// Prints 'Hello World' back to the user.
engine.Destroy()
} |
@adamlc I had the same problem, luckily I did not need curl so in the Dockerfile I removed the Not perfect but it got me got me a bit further along in the process. |
Assuming a folder containing a single file,
You get a binary
I'll see about getting these linked statically as well, since the host system might not provide them. |
Not sure if if anything to go with the host OS (macOS here). But building the container from #55 and running as above I get the following:
If I install libreadline-dev before then I get the curl error again:
|
That's strange, was the I'll need to have different tags for static and non-static images, and push those to the Docker registry, to avoid confusion. The Go build system makes this unnecessarily complex, but I'll try and get a one-command solution here. |
@deuill yep!
|
Thanks for the info, it might be a Mac OS thing, but I can't imagine how (Docker-on-Mac is known to do weird stuff, however). AFAICT you don't need readline, that's what Does |
Here the output (had to specify the path to make)
|
Seems to work (failed tests are known issues ATM). Not sure why your binary is failing, but I'll try and get to the bottom of it. |
No worries, if you need anything from me give me a shout :) |
Nice one @deuill I followed your instructions and got a successful binary to be built. (I am using a Ubuntu VM). However I ran into the issue that you mentioned about missing underlying libraries. Thanks for the help so far. I had a look to see if I could find anything around bringing those libraries but I am out of my depth to be honest. |
It appears that PHP has issues with building statically against its own dependencies, and I'll have to follow up on their mailing lists and see what can be done there. I assume there's some license issues that prevent them from doing so. Until then, I'm afraid you'll have to provide the libraries ( |
@deuill that was where I got stuck also |
Hi,
I am thinking about using this library for a project however I need to build a portable binary which I can easily move between different systems
I had a look at the issue queue and I noticed two items that are interesting.
#39 (comment)
and
#52 (comment)
So it looks like it's possible however I am struggling to work out how to actually do it! Can anyone point me in a direction of how implement this?
Thanks,
Stephen
The text was updated successfully, but these errors were encountered: