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

Embed PHP interpreter through PHP API, a replacement for CGI #3

Closed
GoogleCodeExporter opened this issue Aug 28, 2015 · 16 comments
Closed

Comments

@GoogleCodeExporter
Copy link

Currently we are running php web-server at http://127.0.0.1:54007/, the 
downside of it is that it can cause some troubles with firewalls, when running 
application they they may ask user whether this application is allowed to 
listen at 127.0.0.1 on port 54007.

We should make this an option whether we want to act as a web-server or execute 
scripts directly by running command "php.exe -f myscript.php".

The possible advantage of running as a webserver might be a better performance, 
but there is only one user connecting to that web-server in our case, so the 
gain is dubious.

Original issue reported on code.google.com by czarek.t...@gmail.com on 13 Jan 2013 at 1:15

@GoogleCodeExporter
Copy link
Author

Running "php.exe -f myscript.php" does resolve the firewall issue, as executing 
such command will also cause a firewall prompt. The ideal solution is to 
execute PHP script through PHP API, in PHP binaries there is a "dev/php5.lib" 
file, it looks like a static lib for the php5.dll, what we need is a php5.h 
header so we can call PHP API directly through php5.dll with no need to execute 
php5.exe. There seems to be no single "php5.h" file, it is probably required to 
download all sources codes of php5 from here:
http://windows.php.net/download/#php-5.4 > "Download source codes".

Original comment by czarek.t...@gmail.com on 13 Jan 2013 at 2:46

@GoogleCodeExporter
Copy link
Author

This will not work, unless we can implement a custom scheme,
without it we have no way to listen for coming requests.

Implementing a custom scheme is possible with Chrome, I'm not
sure about Internet Explorer, this feature will probably be
implemented only for Chrome.

Original comment by czarek.t...@gmail.com on 13 Jan 2013 at 6:24

  • Changed title: Chrome: execute scripts directly through PHP API call with no web-server listening

@GoogleCodeExporter
Copy link
Author

When executing php script directly how do we set the document root?

Original comment by czarek.t...@gmail.com on 14 Jan 2013 at 8:51

@GoogleCodeExporter
Copy link
Author

The source of the "php.exe" can be found in sapi/cli/php_cli.c, function that 
interests us is "php_execute_script":

https://github.com/php/php-src/blob/master/sapi/cli/php_cli.c#L988

Original comment by czarek.t...@gmail.com on 15 Jan 2013 at 5:08

@GoogleCodeExporter
Copy link
Author

Calling PHP API directly would require implementing multi-threading
if we want to support handling multiple requests at the same time.
PHP built-in webserver is also single threaded, it cannot handle more
than one request at the same time, see Issue 14.

Original comment by czarek.t...@gmail.com on 15 Jan 2013 at 5:27

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

We will still need a web-server, otherwise submitting forms and uploading files
won't work. The solution would be to implement a virtual file system (VFS) in 
the
mongoose web-server. Or maybe PHP API already has a VFS mechanism?

Original comment by czarek.t...@gmail.com on 2 Feb 2013 at 3:38

  • Changed title: Chrome: execute scripts using PHP API calls

@GoogleCodeExporter
Copy link
Author

VFS in mongoose web-server is not enough, as php scripts include other php
scripts, so it must be some kind of VFS in PHP API.

Original comment by czarek.t...@gmail.com on 2 Feb 2013 at 3:53

  • Changed title: Execute PHP scripts through PHP API

@GoogleCodeExporter
Copy link
Author

We need VFS in both Mongoose & PHP API.

Original comment by czarek.t...@gmail.com on 2 Feb 2013 at 3:56

@GoogleCodeExporter
Copy link
Author

To use an in-memory file system in Mongoose web-server you have to
implement "open_file" callback, example here:

https://github.com/valenok/mongoose/blob/ee55d38b5592cbb55b78c74c2c36fc768fc22a0
7/test/unit_test.c#L192

Original comment by czarek.t...@gmail.com on 2 Feb 2013 at 5:29

@GoogleCodeExporter
Copy link
Author

See this topic for an in-memory filesystem with Mongoose:
https://groups.google.com/d/topic/mongoose-users/JhNQFKC_0wI/discussion

Original comment by czarek.t...@gmail.com on 2 Feb 2013 at 5:57

@GoogleCodeExporter
Copy link
Author

See Kroll's PHP module:
https://github.com/appcelerator/kroll/tree/master/modules/php

Original comment by czarek.t...@gmail.com on 4 Feb 2013 at 4:22

@GoogleCodeExporter
Copy link
Author

[deleted comment]

1 similar comment
@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

When PHP is run in other way than through CGI, memory leaks might be a problem.

Original comment by czarek.t...@gmail.com on 13 Feb 2013 at 6:11

@GoogleCodeExporter
Copy link
Author

This is not a good idea to execute PHP using the PHP API, as PHP was never 
intended to run long hours and this could result in memory leaks.

Original comment by czarek.t...@gmail.com on 19 Jan 2014 at 7:24

  • Changed state: WontFix

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

1 participant