indeyets / appserver-in-php Goto Github PK
View Code? Open in Web Editor NEWGeneric HTTP applications approach for PHP5.3+ (inspired by Rack and WSGI)
License: BSD 3-Clause "New" or "Revised" License
Generic HTTP applications approach for PHP5.3+ (inspired by Rack and WSGI)
License: BSD 3-Clause "New" or "Revised" License
I have an issue with the Symfony AiP bundle where I need to make it configurable (to support multiple applications in different URLs defined by user).
The easiest way to accomplish this would be to enable my aip.yaml
to contain the mappings, as then user would only need to mess with one YAML file.
I'm trying to work around issue #23. For this, I tried to simply use a custom storage implementation that has my patch (LOCK_SH) in it.
Unfortunately, nearly everything inside the Session middleware is private, so for making a simple patch to lock()
I have to copy nearly everything. Not just because most of the stuff is private, but because most methods directly access the properties (instead of using a getter).
This makes it extremely hard and ugly to subclass AiP. I would suggest using protected more often and/or introducing some getters where properties must be private.
http://php.net/manual/en/language.namespaces.importing.php
"Note that for namespaced names (fully qualified namespace names containing namespace separator, such as Foo\Bar as opposed to global names that do not, such as FooBar), the leading backslash is unnecessary and not allowed, as import names must be fully qualified, and are not processed relative to the current namespace. "
I've ran into a real manifestation of this, because Transport/Socket.php uses Transport/Socket/RuntimeException, but the autoloader can't find it, because the namespace of the requester file isn't passed to the autoloader. So one must use fully-qualified names.
Lots of these notices in console while running appserver. I'm not really sure if they affect performance in anyway, but there seems to be some random crashes and this propably should be investigated.
Notice: fwrite(): send of 1024 bytes failed with errno=32 Broken pipe in /usr/share/php/AiP/Protocol/HTTP.php on line 159
Call Stack:
0,0031 642704 1. {main}() /usr/bin/aip:0
0,0218 2053416 2. pakeApp->run() /usr/bin/aip:9
0,0242 2222504 3. pakeApp->initAndRunTask() /usr/share/php/pake/pakeApp.class.php:149
0,0244 2227912 4. pakeTask->invoke() /usr/share/php/pake/pakeApp.class.php:246
0,0244 2227912 5. pakeTask->execute() /usr/share/php/pake/pakeTask.class.php:186
0,0247 2229584 6. call_user_func_array() /usr/share/php/pake/pakeTask.class.php:223
0,0247 2229656 7. AiP\Runner\App::run_app() /usr/share/php/pake/pakeTask.class.php:0
0,0370 2855160 8. AiP\Runner->go() /usr/share/php/AiP/Runner/App.php:96
0,0396 2997728 9. AiP\Runner->startWorker() /usr/share/php/AiP/Runner.php:29
0,0559 2997808 10. AiP\Runner->worker() /usr/share/php/AiP/Runner.php:77
0,4001 4544392 11. AiP\Handler\Daemonic->serve() /usr/share/php/AiP/Runner.php:113
0,4001 4544392 12. AiP\Transport\Socket->loop() /usr/share/php/AiP/Handler/Daemonic.php:64
3756,6053 41709480 13. call_user_func() /usr/share/php/AiP/Transport/Socket.php:31
3756,6053 41709544 14. AiP\Handler\Daemonic->onRequest() /usr/share/php/AiP/Transport/Socket.php:0
3756,6172 41736944 15. AiP\Protocol\HTTP->writeResponse() /usr/share/php/AiP/Handler/Daemonic.php:93
3756,6193 41738696 16. AiP\Protocol\HTTP->write() /usr/share/php/AiP/Protocol/HTTP.php:39
3756,6193 41738776 17. fwrite() /usr/share/php/AiP/Protocol/HTTP.php:159
Quoting PAStheLoD:
Hi, please consider the issue of input buffering, especially in the case of handling large file uploads. (And trying to show the user transfer the speed for example.)
Also the request parsing should be able to deal with this. (So, for example, via inheriting from a specific class, one could work together with AiP's request handler to set up where to save the files, put stats into memcache or APC cache, or filter on filename, or inspect the beginning of files for some MIME magic.)
Hi,
The PEAR repo seems to have been pretty much abandoned in favour of Composer. If that's the case it would be good if it were marked as such. Even better would be to keep it up to date of course as Composer isn't appropriate for everyone.
Cheers
I have been assigned the task of writing some tests for a Drupal APP running on top of your appserver.
If xdebug were to be installed on the base PHP, would I be able to set breakpoints, etc in the APP running in your appserver? Since I do not control the dev server, I can't just 'try it'. :) If I 'should' work, I will request to have xdebug installed.
Thank You
After upgrading the aip PEAR package to 0.9.0, my system didn't have the aip file, not in /usr/bin
, or anywhere else.
I'm trying to use AiP with Windows (of course not as a real application server). For this my mod_php will just fire up a PHP script that sets up the autoloading, instantiates my app server class (the same AiP would fire up) and invoke it with some context data.
This works really well, except for the sessions. Sessions cannot be saved and I get the PHP error
Warning: file_put_contents(): Only 0 of 85 bytes written, possibly out of free disk space
Disk space is OK. I can write to the file in question without any problems. Even from PHP, even from the same script and same request. The problem is the file locking, which uses LOCK_EX
. If I add LOCK_SH
, session files are written and the problem goes away.
<?
// AiP/Middleware/Session/Storage/FileStorage.php, line 140
flock($this->_fp, LOCK_EX | LOCK_SH);
I'm no expert on file locking, so I can't recommend this as a general solution (that's why I didn't create a pull request). If however it's no problem for *nix systems to have the LOCK_SH
flag set, I would greatly appreciate having it in there.
In the meantime, I just use a patched version for Windows systems. Since I cannot use Composer to install AiP (requires posix and pcntl extensions), I have to install the vendor stuff by extracting a zip file anyway. So it's not super urgent to be fixed.
Hi,
Having a go with this and loving the speed boost.
Found that the following breaks upload fields with simple names:
$sel = preg_replace('/([^[]]+)/', ''\1'', $disposition['name']);
(which is around line 206 or so of /Middleware/PHP_Compat/PHP_Compat.class.php)
In the case of a field named simply, for example, 'upload', the field has its key in the $_FILES array set as 'upload' (i.e including the single quotes).
Hello,
I would like to propose a new layout of catalogues which will be adapted to the class SplClassLoader: http://github.com/metagoto/splclassloader (which will be implemented in PHP in the near future). Then layout of catalogues would change on that:
--bin
----aip (actually /Runner/bin/aip)
--library
-----MFS
--------AppServer
-----------iProtocol (maybe Protocol?)
--------------HTTP
-----------------Server.php
--------------SCGI
-----------------Server.php
-----------------Client.php
-----------------Response.php
...etc...
Regards
deallas
Workaround: http://php.net/manual/en/function.pcntl-signal-dispatch.php from http://bugs.php.net/bug.php?id=47198
Although ticks were deprecated at some point, I can't find any relevant discussion about it, nor the docs say anything like that.
So, it's not really a party killer, but it'd be nice to do without it. Plus it helps tracing running instances.
I have installed appserver-in-php
and started the appserver per instructions.
root@AIP:/var/www/html/aip# ./bin/aip app examples/new/aip.yaml
Loading configuration…
[app+] MyApp server via HTTP at tcp://127.0.0.1:8080. (5-10 workers)
[app+] MyApp server via SCGI at tcp://127.0.0.1:9999. (1-2 workers)
Starting workers…
I have hit the URL:
http://x.x.x.x/aip/examples/new/template.html
I have tried entering various inputs. No indication of anything functioning or results returned.
What next?
Thank You
As with pake, a new release would come handy for users without git on their machines.
I assume you are going to tag soon anyway, so this is just a reminder :-)
В карте задается путь или url? Почему там анализируется PATH_INFO, а не REQUEST_URI? В общем у меня 404, и не знаю кто не прав - PHP_Compat или URLMap
We need a FastCGI connector. FastCGI support is more widely available than SCGI support and protocol is more capable in general (multiplexing support).
The plan is to implement FastCGI connector using php's fastcgi library (fastcgi library -> pecl/fastcgi -> fastcgi connector)
Hi Alexey,
I have just installed via composer and try to run my app.
Here is what I am getting. Can you please addd them as dependencies in your composer definition file.
thanks
ponyo-mba~/www/worldsoft/projects/ws_wbs/wbs_backend> /usr/local/bin/php -v
PHP 5.4.19 (cli) (built: Sep 18 2013 11:14:22)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
ponyo-mba~/www/worldsoft/projects/ws_wbs/wbs_backend> /usr/local/bin/php vendor/bin/aip app aip.dev.yaml
Loading configuration…
PHP Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in /Users/aghaffar/www/clients/worldsoft/projects/ws_wbs/wbs_backend/vendor/aip/aip/AiP/Runner/AppCommand.php on line 40
Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in /Users/aghaffar/www/clients/worldsoft/projects/ws_wbs/wbs_backend/vendor/aip/aip/AiP/Runner/AppCommand.php on line 40
When using the FileServe app with the Compress middleware I get the following exception:
PHP Warning: gzdeflate() expects parameter 1 to be string, resource given in /opt/local/lib/php/AiP/Middleware/Compress.php on line 31
PHP Stack trace:
PHP 1. {main}() /opt/local/bin/aip:0
PHP 2. pakeApp->run() /opt/local/bin/aip:9
PHP 3. pakeApp->initAndRunTask() /opt/local/lib/php/pake/pakeApp.class.php:149
PHP 4. pakeTask->invoke() /opt/local/lib/php/pake/pakeApp.class.php:246
PHP 5. pakeTask->execute() /opt/local/lib/php/pake/pakeTask.class.php:186
PHP 6. call_user_func_array() /opt/local/lib/php/pake/pakeTask.class.php:223
PHP 7. AiP\Runner\App::run_app() /opt/local/lib/php/pake/pakeTask.class.php:0
PHP 8. AiP\Runner->go() /opt/local/lib/php/AiP/Runner/App.php:96
PHP 9. AiP\Runner->startWorker() /opt/local/lib/php/AiP/Runner.php:29
PHP 10. AiP\Runner->worker() /opt/local/lib/php/AiP/Runner.php:77
PHP 11. AiP\Handler\Daemonic->serve() /opt/local/lib/php/AiP/Runner.php:113
PHP 12. AiP\Transport\Socket->loop() /opt/local/lib/php/AiP/Handler/Daemonic.php:64
PHP 13. call_user_func() /opt/local/lib/php/AiP/Transport/Socket.php:31
PHP 14. AiP\Handler\Daemonic->onRequest() /opt/local/lib/php/AiP/Transport/Socket.php:0
PHP 15. call_user_func() /opt/local/lib/php/AiP/Handler/Daemonic.php:87
PHP 16. AiP\Middleware\Logger->__invoke() /opt/local/lib/php/AiP/Handler/Daemonic.php:0
PHP 17. call_user_func() /opt/local/lib/php/AiP/Middleware/Logger.php:59
PHP 18. AiP\Middleware\Compress->__invoke() /opt/local/lib/php/AiP/Middleware/Logger.php:0
PHP 19. gzdeflate() /opt/local/lib/php/AiP/Middleware/Compress.php:31
Warning: gzdeflate() expects parameter 1 to be string, resource given in /opt/local/lib/php/AiP/Middleware/Compress.php on line 31
Call Stack:
0.0002 630136 1. {main}() /opt/local/bin/aip:0
0.0071 1887344 2. pakeApp->run() /opt/local/bin/aip:9
0.0081 2037696 3. pakeApp->initAndRunTask() /opt/local/lib/php/pake/pakeApp.class.php:149
0.0082 2041480 4. pakeTask->invoke() /opt/local/lib/php/pake/pakeApp.class.php:246
0.0082 2041480 5. pakeTask->execute() /opt/local/lib/php/pake/pakeTask.class.php:186
0.0084 2042608 6. call_user_func_array() /opt/local/lib/php/pake/pakeTask.class.php:223
0.0084 2042648 7. AiP\Runner\App::run_app() /opt/local/lib/php/pake/pakeTask.class.php:0
0.0159 2621928 8. AiP\Runner->go() /opt/local/lib/php/AiP/Runner/App.php:96
0.0197 2750440 9. AiP\Runner->startWorker() /opt/local/lib/php/AiP/Runner.php:29
0.0298 2750488 10. AiP\Runner->worker() /opt/local/lib/php/AiP/Runner.php:77
0.0386 3568136 11. AiP\Handler\Daemonic->serve() /opt/local/lib/php/AiP/Runner.php:113
0.0387 3568136 12. AiP\Transport\Socket->loop() /opt/local/lib/php/AiP/Handler/Daemonic.php:64
1.9608 3568896 13. call_user_func() /opt/local/lib/php/AiP/Transport/Socket.php:31
1.9608 3568928 14. AiP\Handler\Daemonic->onRequest() /opt/local/lib/php/AiP/Transport/Socket.php:0
1.9615 3583256 15. call_user_func() /opt/local/lib/php/AiP/Handler/Daemonic.php:87
1.9615 3583288 16. AiP\Middleware\Logger->__invoke() /opt/local/lib/php/AiP/Handler/Daemonic.php:0
1.9617 3584768 17. call_user_func() /opt/local/lib/php/AiP/Middleware/Logger.php:59
1.9617 3584800 18. AiP\Middleware\Compress->__invoke() /opt/local/lib/php/AiP/Middleware/Logger.php:0
1.9645 3780560 19. gzdeflate() /opt/local/lib/php/AiP/Middleware/Compress.php:31
PHP Notice: Undefined variable: len in /opt/local/lib/php/AiP/Middleware/Logger.php on line 71
PHP Stack trace:
PHP 1. {main}() /opt/local/bin/aip:0
PHP 2. pakeApp->run() /opt/local/bin/aip:9
PHP 3. pakeApp->initAndRunTask() /opt/local/lib/php/pake/pakeApp.class.php:149
PHP 4. pakeTask->invoke() /opt/local/lib/php/pake/pakeApp.class.php:246
PHP 5. pakeTask->execute() /opt/local/lib/php/pake/pakeTask.class.php:186
PHP 6. call_user_func_array() /opt/local/lib/php/pake/pakeTask.class.php:223
PHP 7. AiP\Runner\App::run_app() /opt/local/lib/php/pake/pakeTask.class.php:0
PHP 8. AiP\Runner->go() /opt/local/lib/php/AiP/Runner/App.php:96
PHP 9. AiP\Runner->startWorker() /opt/local/lib/php/AiP/Runner.php:29
PHP 10. AiP\Runner->worker() /opt/local/lib/php/AiP/Runner.php:77
PHP 11. AiP\Handler\Daemonic->serve() /opt/local/lib/php/AiP/Runner.php:113
PHP 12. AiP\Transport\Socket->loop() /opt/local/lib/php/AiP/Handler/Daemonic.php:64
PHP 13. call_user_func() /opt/local/lib/php/AiP/Transport/Socket.php:31
PHP 14. AiP\Handler\Daemonic->onRequest() /opt/local/lib/php/AiP/Transport/Socket.php:0
PHP 15. call_user_func() /opt/local/lib/php/AiP/Handler/Daemonic.php:87
PHP 16. AiP\Middleware\Logger->__invoke() /opt/local/lib/php/AiP/Handler/Daemonic.php:0
Notice: Undefined variable: len in /opt/local/lib/php/AiP/Middleware/Logger.php on line 71
Call Stack:
0.0002 630136 1. {main}() /opt/local/bin/aip:0
0.0071 1887344 2. pakeApp->run() /opt/local/bin/aip:9
0.0081 2037696 3. pakeApp->initAndRunTask() /opt/local/lib/php/pake/pakeApp.class.php:149
0.0082 2041480 4. pakeTask->invoke() /opt/local/lib/php/pake/pakeApp.class.php:246
0.0082 2041480 5. pakeTask->execute() /opt/local/lib/php/pake/pakeTask.class.php:186
0.0084 2042608 6. call_user_func_array() /opt/local/lib/php/pake/pakeTask.class.php:223
0.0084 2042648 7. AiP\Runner\App::run_app() /opt/local/lib/php/pake/pakeTask.class.php:0
0.0159 2621928 8. AiP\Runner->go() /opt/local/lib/php/AiP/Runner/App.php:96
0.0197 2750440 9. AiP\Runner->startWorker() /opt/local/lib/php/AiP/Runner.php:29
0.0298 2750488 10. AiP\Runner->worker() /opt/local/lib/php/AiP/Runner.php:77
0.0386 3568136 11. AiP\Handler\Daemonic->serve() /opt/local/lib/php/AiP/Runner.php:113
0.0387 3568136 12. AiP\Transport\Socket->loop() /opt/local/lib/php/AiP/Handler/Daemonic.php:64
1.9608 3568896 13. call_user_func() /opt/local/lib/php/AiP/Transport/Socket.php:31
1.9608 3568928 14. AiP\Handler\Daemonic->onRequest() /opt/local/lib/php/AiP/Transport/Socket.php:0
1.9615 3583256 15. call_user_func() /opt/local/lib/php/AiP/Handler/Daemonic.php:87
1.9615 3583288 16. AiP\Middleware\Logger->__invoke() /opt/local/lib/php/AiP/Handler/Daemonic.php:0
Hi Alexey,
Hope you are doing well.
I and starting my app with
aip app somefile.yaml
Is there a possibility to implement
aip app somefile.yaml graceful (similar to apachectl graceful)
method which will restart all the children once they have finished doing the current task?
For the older projects I am using a very old version of AIP with homegrown stop handlers for each process that is listening on a specific port (one process per port).
I want to use now for the next project the official version with multiple processes on the same port and let AIP take care of the loadbalancing of the processes than use an external loadbalancer.
Let me know if you need my help.
Atif
Using PHP 5.3.8/5.3.9, it takes a long time (1-2 minutes) until the call to stream_get_line() in the HTTP connector returns. This seems to be an upstream bug: https://bugs.php.net/bug.php?id=60817
Opera 10.60 beta produces multipart-requests, incompatible with appserver's code in PHP_Compat middleware.
After running composer install
I try to run vendor/bin/aip app mongrel2.yaml
in the application's root. It ends up with this error message:
/vendor/bin/aip: @PHP-BIN@: bad interpreter: No such file or directory
Seems to be some token @PHP-BIN@
there that wasn't exchanged with the correct value?
AiP in MeeGo Apps produces a fatal error when starting:
Fatal error: Cannot re-assign auto-global variable _POST in /usr/share/php/AiP/Middleware/HTTPParser.php on line 91
Environment: Debian unstable (x86_64 arch)
$ php -v
PHP 5.4.4-7 (cli) (built: Aug 30 2012 08:57:09)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
We need HTTP/1.0 connector. This way it will be possible to run applications locally without need for additional server-software and to use HTTP-proxy servers (such as squid) as a mean of deployment
The problem seems to be with the _ (underscore) character. The autoloader tries to load MOD/PHP.php instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.