Created
May 13, 2013 11:13
-
-
Save afroald/5567613 to your computer and use it in GitHub Desktop.
How I run Laravel websites in Rack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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