slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.94k stars 1.95k forks source link

Remove base path concept #2054

Closed codeguy closed 7 years ago

codeguy commented 7 years ago

Just remove it entirely. Let web server configuration handle edge case base path scenarios.

geggleto commented 7 years ago

yikes.... this one is going to cause a lot of pain...

I suppose in the end this is a content rendering problem, which can be handled at a twig level.

We should at least document a good way on how to extract the base-path in the framework, or provide a function call to do that.

pine3ree commented 7 years ago

Hello @geggleto, the basePath/baseUrl can be set with an early middleware. This also makes the entire application more portable and "mountable" inside existing site/applications path. There are 2 ways to implement a basePath middleware:

  1. path/url extrapolation from environment
  2. path/url manually set

I used to prefer option 1. Lately I use option 2 more often...less overhead. Moving an application is a developer's task, so path/url can be re-set "manually" at the same time. Option 1 is still required on some edge cases lile for instance when the same site is hosted on different domains/vhosts with different base paths / urls.

kind regards maks

codeguy commented 7 years ago

PR submitted https://github.com/slimphp/Slim/pull/2087

geggleto commented 7 years ago

I'm still on the fence... While I know most of us will accept this change it will be hard for newer developers to learn Slim in an easy envrionment, ie Windows XAMPP.

We will have to make sure documentation is updated to accommodate this change.