Skip to content

Instantly share code, notes, and snippets.

@afroald
Created May 13, 2013 11:13
Show Gist options
  • Save afroald/5567613 to your computer and use it in GitHub Desktop.
Save afroald/5567613 to your computer and use it in GitHub Desktop.
How I run Laravel websites in Rack
# Inspired by https://coderwall.com/p/splmua
require 'rubygems'
require 'bundler/setup'
require 'rack'
require 'rack-rewrite'
require 'rack-legacy'
public_dir = File.join(Dir.getwd, 'public')
use Rack::Rewrite do
rewrite %r{(.*)?}, lambda {|match, rack_env|
if rack_env['PATH_INFO'].include?('assets') or File.exists?(File.join(public_dir, match[1]))
return match[1]
else
"/index.php" + match[1]
end
}
end
use Rack::Legacy::Php, File.join(public_dir)
run Rack::File.new File.join(public_dir)
source 'https://rubygems.org'
gem "rack", "~> 1.5.2"
gem "rack-rewrite", "~> 1.3.3"
gem "rack-legacy", :git => "git://github.com/Hacquebord-Buckles/rack-legacy.git"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment