I'm developing a PHP app on windows, and so far I've been using the built-in web server of the php executable (https://www.php.net/manual/en/features.commandline.webserver.php).
However, the application now has grown, and it makes many php requests. On windows, the built-in web server does not allow forking and therefore can only answer one request at a time, which makes it very slow.
I'm looking for something very simple, just serve a local folder with php interpreter. It must be a portable solution, just copy/paste to another computer and it works, and it must run multithreaded in windows.
I've been trying the windows subsystem for linux, and running the server there, but I wanted to ask for an alternative. This requires too much installation, I really wanted something much more portable: just copy/paste the folder and run a .bat to start the server.
I'm running Symfony's built-in server during development and noticed that CPU usage of CLI.exe (PHP's command-line interface that's called through php bin/console server:run) is always around 30%, even when idle.
I launch it from a Windows Powershell. Any idea why this happens during idle time?
PHP's built-in web server is only meant to be used during development:
Warning This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
It makes no performance guarantees, and I'm not surprised that it has high CPU utilization.
The Symfony documentation suggests that it is only meant as a convenience:
This way, you don't have to bother configuring a full-featured web server such as Apache or Nginx.
Of course, you are free to run a full-featured web server in development if you want something more tuned to real world use.
Currently I'm working on some PHP porjects. And it's a little bit difficult to navigate always through approximately 100 folders to the destination one. Also it's not very comfortable to create virtual hosts for Apache. And it would be much more comfortable to run from CLI command like "someserver start ." and then just go to the localhost:8080 in favorite web-browser and start enjoying the development process.
If you are thinking along the lines of a built-in server like Mongrel is for Ruby, then No. This doesn't exist for PHP as of PHP 5.3.6. A patch offering that is under discussion though:
CLI version of PHP will have a new command-line option -S followed by a host address (either in numeric or alphabetic) and a port number delimited by a colon, which will launch a builtin web server listening on the given address and port
php -S localhost:8000 docroot
Links:
Alexey Zakhlestins on PHP's Webserver
PHP Wiki Request for Comments: Built-in web server
Webserver Patch
For a complete self contained web development setup, you can use XAMPP. To simplify things further you can then just develop out of the htdoc or www folder provided by xampp.
I'd like to develop a PHP application that users would download and then could run. The application will have a web service.
I assume they will need Apache, but my main question is what is needed for PHP to run on their machine? Is there something needed like the JVM in Java or the .Net framework in .Net? What is it called and how difficult is it for them to download (size, etc.).
Is anything else required that I did not mention?
Thank you,
They will need a web server with a compatible version of php. That's it.
Are you asking what is required to run a .php file on a windows machine? Do you mean like an executable or a web server script?
If like an executable need the php files:
Download the php installer from http://windows.php.net/download/, and then you can run php.exe script.php
If like a web site:
You need a webserver (like apache) and the php.exe files. I would suggest if testing to download a prebuilt webserver like XAMPP (download from http://www.apachefriends.org/en/xampp-windows.html)
It depends on the application. At a minimum it will need PHP.
Is there something needed like the JVM in Java or the .Net framework in .Net? What is it called and how difficult is it for them to download (size, etc.).
PHP. Presumably as difficult as it is for you, but it depends on the platform. OS X comes with it. Most Linux variants either come with it, or allow it to be installed with one command to the package manager. Windows users will have to download it seperately.
As for other things that might be needed…
If it has a GUI, it might need PHP-GTK.
If it expects to be accessed via HTTP then they will need a webserver which supports PHP. This could be Apache, IIS, or one of numerous other servers.
(It isn't clear if, when you say "The application will have a web service.", you mean "The application will access a web service" or "The application will provide a web service". If the latter, then a web server will be needed).
If you use any non-core modules, then they will be needed as well.
You need to describe your proposed application a bit better. Is there a reason the application must be in PHP? It may be possible, but it's certainly not common to code and distribute a desktop application written in PHP.
There are a few options.
If you are just writing a script (command line, etc) you don't need a webserver. You just need PHP installed to run it (there are even downloadable installers for it).
If you are writing a web-based tool, then you will need your users to have a webserver if they are meant to run it on their physical machines. And you don't need a framework...
just think of it as a Webserver + PHP as a plugin. Some webserver options: Apache, nginx, lighttpd
Try having users install WAMP, MAMP, or Zend Server CE all of which are free and come with both a webserver and PHP.
If you really want a deployable PHP script/tool, maybe look into something like PHPDock, which gives your users a single installable app (embedded server, php). NuSphere PHPDock
Honestly, it's not the greatest language to use for this type of deployment, but it's certainly fun to try to figure out! Sorry for not linking out also, don't have enough rep points for all of the links I had intended to supply.
Actually you can run php script without the need to have a webserver installed.
Just install php and then from command line:
$ php myscript.php
If you really want you can even build GUI application with php even though I would not suggest it.
Cheers Andrea
you could also try to use quercus.
Quercus is Caucho Technology's fast,
open-source, 100% Java implementation
of the PHP language (requires JDK
1.5).
This way you only will need a jvm+quercus. It also is platform independent this way because it runs in the JVM.
We've built a php application that we need to host on a Windows Server 64 bit platform (due to another software being present that we need to access).
However, our php application has been built on a linux environment.
Is there anything we need to be watchful of when running apache and this php application on a Windows environment?
Mostly any PHP script is cross-platform and normally you don't care about platform, but there are some platform-specific things like absolute paths (C:/www | /var/www/) and shell commands. If you don't use them then it will work. If not, it will not take much time for fixing.
There may be some good reading here on the official PHP documentation on running PHP on Windows.