Skip to content
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

documentation or examples lacking..? how to get server-side content from the server into the client-side php..? #54

Open
davidbuzz opened this issue Aug 20, 2024 · 2 comments

Comments

@davidbuzz
Copy link

eg, presuming your "normal" server-side php queries a mysql database and emits the result as json or html fragments or whatever, when the php itself is moved to-the-browser, how does the php now get the "dynamic" part of the data from the database, or from the server endpoint.?

becasue of http same-site security, the client-side php can't be arbitrarily reaching-acoss the network to anything other than the server-from-which it was delivered, and so it either needs to use long-polling or websockets to get that data, or php-wasm-cgi forwards the call up-stream to the server that delivered the http request in the first place...?

an example of this sort of dynamic constent is the entire reason php is on the "server" these days, so being unable to do it is massive thorn in the value it offers by putting it in-the-browser.

@seanmorris
Copy link
Owner

seanmorris commented Oct 11, 2024

@davidbuzz I just pushed out an update to Vrzno that enables url_fopen, so you should just be able to call $data = file_get_contents("https://YOUR_URL_HERE"); to pull data from a remote server. So long as CORS is enabled, it should work just like regular url_fopen. It runs a fetch() based GET request in the background.

Edit: example here: https://codepen.io/SeanMorris227/pen/poMRoyN?editors=1000

@blackjyn
Copy link

thanks @seanmorris .
Im trying yoru sample locally , working just fine with :

<script async type = "module" src = "https://cdn.jsdelivr.net/npm/[email protected]/php-tags.mjs"></script>

but NOT with

<script async type="module" src="node_modules/php-wasm/php-tags.mjs"></script>

I updated the deps to [email protected] , but didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants