Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatch() assumes app is not served from a subdirectory #5

Closed
jamesvl opened this issue Apr 8, 2011 · 1 comment
Closed

dispatch() assumes app is not served from a subdirectory #5

jamesvl opened this issue Apr 8, 2011 · 1 comment

Comments

@jamesvl
Copy link

jamesvl commented Apr 8, 2011

I know you're not trying to make this everything to everybody - it's already quite fantastic as it stands. I fully understand if this is more than you'd want to include.

Description

The current setup always assumes klein is being using from the server's root. If I have multiple apps I want to serve independently of one another in various subdirectories, that assumption doesn't hold.

Solution Option 1

The code would be in the section that defines the $uri variable, right after the part where you trim off the query string

<?php
if ($appDir != '/' AND strpos($uri, $appDir) !== false) {
   $uri = substr($uri, strlen($appDir));
}
?>

I can do a pull request for the code if you like, but I thought you would be best able to determine how a user can define their $appDir.

Solution Option 2

You could leave query string munging up to the user. They're responsible for stripping out their $appDir prefix and must always pass an explicit URI to dispatch().

However, then they would also need to know when or if to trim off the query string, or handle whatever other future cases you have in your portion of the URI code.

@chriso
Copy link
Contributor

chriso commented Apr 10, 2011

I decided to leave this feature out. klein has no configuration so incorporating an app path wouldn't really fit with what I was going for. I'll push a new version tomorrow which trims off the query string for user specified URI's. It becomes trivial for users to implement this themselves:

define('APP_PATH', '/myapp');
dispatch(substr($_SERVER['REQUEST_URI'], strlen(APP_PATH)));

@chriso chriso closed this as completed Apr 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants