Open hookenz opened 1 week ago
Ok I seems I need to install watcher.
Why I went wrong here is because the documentation says
Install "Optional" Dependencies.
Since the title says "Optional". I skipped it. But it's not optional unless you turn those features off in the configure step I think? That's unclear. I suggest you amend the documentation.
Unfortunately, watcher has really bad documentation on how to actually install it and make it available. According to the watcher docs, I followed the steps and watcher is still not found. And it's been way too many years that I have forgotten how the C compiler finds files. From memory, INCLUDE environment vars or something. But there simply are no examples to get this off the ground with golang. It's a horrible onboarding experience.
Looks like I can copy the watcher includes to: sudo cp -rp watcher-next/include/wtr /usr/local/include/
So this problem is resolved but now I get
❯ go build .
# github.com/dunglas/frankenphp
../go/pkg/mod/github.com/dunglas/frankenphp@v1.3.0/cgi.go:3:11: fatal error: php_variables.h: No such file or directory
3 | // #include <php_variables.h>
| ^~~~~~~~~~~~~~~~~
compilation terminated.
Next battle. That's a file in the php sources. Yeah, please provide more thorough examples from start to finish. Nothing quite works out of the gate.
To build without the watcher you can do something like this in the meantime I think:
go build -tags nowatcher
I got a little further.
❯ CGO_CFLAGS="-I/home/hookenz/franken/php-8.2.25/main -I/home/hookenz/franken/php-8.2.25/Zend -I/home/hookenz/franken/php-8.2.25 -I /home/hookenz/franken/php-8.2.25/TSRM" go build .
# frank
/snap/go/10743/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/gcc -m64 -o $WORK/b001/exe/a.out -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=crosscall2 -Wl,--export-dynamic-symbol=go_apache_request_headers -Wl,--export-dynamic-symbol=go_frankenphp_finish_request -Wl,--export-dynamic-symbol=go_frankenphp_release_known_variable_keys -Wl,--export-dynamic-symbol=go_frankenphp_worker_handle_request_start -Wl,--export-dynamic-symbol=go_getenv -Wl,--export-dynamic-symbol=go_getfullenv -Wl,--export-dynamic-symbol=go_handle_file_watcher_event -Wl,--export-dynamic-symbol=go_handle_request -Wl,--export-dynamic-symbol=go_log -Wl,--export-dynamic-symbol=go_putenv -Wl,--export-dynamic-symbol=go_read_cookies -Wl,--export-dynamic-symbol=go_read_post -Wl,--export-dynamic-symbol=go_register_variables -Wl,--export-dynamic-symbol=go_sapi_flush -Wl,--export-dynamic-symbol=go_sapi_getenv -Wl,--export-dynamic-symbol=go_shutdown -Wl,--export-dynamic-symbol=go_ub_write -Wl,--export-dynamic-symbol=go_write_headers -Wl,--compress-debug-sections=zlib /tmp/go-link-124271613/go.o /tmp/go-link-124271613/000000.o /tmp/go-link-124271613/000001.o /tmp/go-link-124271613/000002.o /tmp/go-link-124271613/000003.o /tmp/go-link-124271613/000004.o /tmp/go-link-124271613/000005.o /tmp/go-link-124271613/000006.o /tmp/go-link-124271613/000007.o /tmp/go-link-124271613/000008.o /tmp/go-link-124271613/000009.o /tmp/go-link-124271613/000010.o /tmp/go-link-124271613/000011.o /tmp/go-link-124271613/000012.o /tmp/go-link-124271613/000013.o /tmp/go-link-124271613/000014.o /tmp/go-link-124271613/000015.o /tmp/go-link-124271613/000016.o /tmp/go-link-124271613/000017.o /tmp/go-link-124271613/000018.o /tmp/go-link-124271613/000019.o /tmp/go-link-124271613/000020.o /tmp/go-link-124271613/000021.o /tmp/go-link-124271613/000022.o /tmp/go-link-124271613/000023.o /tmp/go-link-124271613/000024.o /tmp/go-link-124271613/000025.o /tmp/go-link-124271613/000026.o /tmp/go-link-124271613/000027.o /tmp/go-link-124271613/000028.o /tmp/go-link-124271613/000029.o /tmp/go-link-124271613/000030.o /tmp/go-link-124271613/000031.o -O2 -g -lresolv -L/usr/local/lib -L/usr/lib -lphp -ldl -lm -lutil -O2 -g -lresolv -O2 -g -lpthread -O2 -g -lwatcher-c -lstdc++ -O2 -g -no-pie
/usr/bin/ld: cannot find -lphp: No such file or directory
collect2: error: ld returned 1 exit status
Ok, I've solved it. I need to "install" the PHP binary and all it's development files with.
So after the ./configure
step.
sudo make install
.
Then simply run go build .
I also needed to copy the watcher
sudo cp -rp watcher-next/include/wtr /usr/local/include/
It would be awesome if the docs could be updated with more full and clear examples. But I think I got there in the end.
Don't hesitate to send docs PR, improving this is on my (long) todo list, but any help is welcome.
Ok, I've solved it. I need to "install" the PHP binary and all it's development files with.
Don't forget it needs to be a ZTS build @hookenz!
What happened?
I grabbed an example of using Franken as a go library
I thought perhaps watcher-c.h is in the php code? but I can't locate it. Where does that file come from?
Build Type
Custom (tell us more in the description)
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output