Skip to content

Instantly share code, notes, and snippets.

@goofrider
Created June 23, 2013 22:24
Show Gist options
  • Save goofrider/5846759 to your computer and use it in GitHub Desktop.
Save goofrider/5846759 to your computer and use it in GitHub Desktop.
Serving PHP apps locally with with pow and rack-legacy http://stuff-things.net/2011/05/16/legacy-development-with-pow/
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
INDEXES = ['index.html','index.php', 'index.cgi']
use Rack::Rewrite do
rewrite %r{(.*/$)}, lambda {|match, rack_env|
INDEXES.each do |index|
if File.exists?(File.join(Dir.getwd, rack_env['PATH_INFO'], index))
return rack_env['PATH_INFO'] + index
end
end
rack_env['PATH_INFO']
}
end
use Rack::Legacy::Php, Dir.getwd
use Rack::Legacy::Cgi, Dir.getwd
run Rack::File.new Dir.getwd
source 'https://rubygems.org'
gem 'Rack-legacy'
gem 'rack-rewrite'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment