Skip to content

support for serving php files #270

wants to merge 2 commits into from

9 participants

fgnass commented Aug 30, 2012

With these small changes yeoman server can serve php files directly through php-cgi.
You can find a screencast and some background here:
Please let me know what you think about the idea.

Yeoman member

Nice work! Some interesting refactoring going on there :)


  • Lets test this to make sure the introduction of tamper and gateway doesn't cause any breakages elsewhere
  • That these additional dependencies don't add that much extra time to the installation process
  • The modifications to server pass tests, continue serving correctly other content and so on.


  • We're aiming to launch on Monday. Is it a good idea for us to consider this so closely? leave for V2?
  • Does merging open up a gateway for developers asking us to add other language-specific additions?
fgnass commented Aug 30, 2012

Thanks, I'm glad you like it.

About your last concern: The only PHP-specific part ist the mapping from the file-extension to the name of the CGI interpreter. Everything else RFC 3875 which is completely language agnostic. A good idea would probably be to put these mappings into the Gruntfile so that developers can add their own.

About the size of the new dependencies: Both new modules tamper and gateway don't have any further external dependencies and consist of only one single file. The largest part of both modules are their unit tests ;)

BTW, the tamper test-suite checks if the server behaves in the same way with and without the middleware in place (even for large files). But I absolutely agree that we should thoroughly test that this doesn't break anything.

mklabs commented Aug 30, 2012

I applaud and appreciate the effort, but this is IMHO a bad idea.

If you intent is to be able to use yeoman server for its livereload ability, you should rely on the livereload extensions and avoid the need of any script injection. You can then use any kind of HTTP server, you'll just need to start yeoman server without using it as an HTTP server, just for the file watch and notification to livereload.js

To be able to establish the connection, you'll need to force the port to 35729 in the Gruntfile config, with server.port=35729.

I've tested it on a dummy wordpress install and now using it extensively at work on a symfony project.

fgnass commented Aug 30, 2012

I think the script injection is actually a pretty rad feature as it allows you to live-reload sites even in ancient browsers as well as on mobile devices (without having to use tools like Adobe Shadow). So this is super useful for cross-browser testing.

Yeoman member

I like it. Nice work @fgnass
I think we'll wait a little bit and let the 1.0 ship, but I'd like to return to this feature soon.

pederan commented Sep 17, 2012

I really would like php support in Yeoman, but can't make it work. I have installed php-cgi, but just don't get how to load the gateway module and initialize tamper. Can you please explain, or upload your example project? Thx


I have tried gateway and tamper. They can not work properly, following error occurred.
Can't set headers after they are sent.

fgnass commented Sep 30, 2012

@blueyestar That issue should have been fixed in gateway@0.1.1. If it still happens with the latest version, it would be nice if you could file a bug over at

Yeoman member

Just a heads up.

I landed this middleware option in grunt-contrib-connect (formerly grunt-contrib-server), which lets you easily hook in your own middlewares.

We're going to use grunt-contrib-connect in the future, so this will make it possible for users to easily hook in this PHP as a middleware.


I'm going to close this for now, but will definitely reopen if we decide to include support for PHP when we explore back-end support.


I hope this is still being considered!


How can this be configured on sytem which has ubuntu 12.10 as its Operating System?

@sindresorhus sindresorhus referenced this pull request Mar 8, 2013

Docs for 1.0 #829

8 of 14 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.