Giter Site home page Giter Site logo

Problem with Windows about slim HOT 9 CLOSED

slimphp avatar slimphp commented on May 3, 2024
Problem with Windows

from slim.

Comments (9)

bobdia avatar bobdia commented on May 3, 2024

Perhaps the built-in DIRECTORY_SEPARATOR constant would be handy.

from slim.

codeguy avatar codeguy commented on May 3, 2024

@bobdia Perhaps. In this case, Request::$root is the public-accessible URI to the directory in which the Slim app is installed. Most of the times, this will be "/", but it could be "/foo" or "/foo/bar" and so on. I believe DIRECTORY_SEPARATOR will be "" on Windows so not necessarily useful when constructing URIs. This should be an easy fix... just need to get to it here soon is all.

from slim.

bobdia avatar bobdia commented on May 3, 2024

Just thought I'd mention it. "/" will work on windows so should be simpler to always use that. Let me know if you need someone to test on Windows.

from slim.

codeguy avatar codeguy commented on May 3, 2024

Absolutely. I'll post another message here when I push up the changes so you can test. Thanks!

from slim.

codeguy avatar codeguy commented on May 3, 2024

I'm not at all familiar with IIS, and I believe this issue is specific to that server. If anyone else can chip in and provide a solution for this, that'd be much appreciated. Until then, I'm lowering the priority of this ticket.

from slim.

phaseinducer avatar phaseinducer commented on May 3, 2024

I run a WAMP server with the latest dev version and I had a similar problem : my URI root was "" so all my generated URLs were incorrect. This is due to the different behaviour of dirname() on Windows, called in Uri::getBaseUri() (line 71).

I fixed it like this :
$baseUri = strpos($requestUri, $scriptName) === 0 ? $scriptName : dirname($scriptName);

replaced by :
$baseUri = strpos($requestUri, $scriptName) === 0 ? $scriptName : str_replace('', '/', dirname($scriptName));

It's not very pretty but effective.
I tested it with and without a controller call and also with the app installed in a sub-directory.

from slim.

codeguy avatar codeguy commented on May 3, 2024

Nice! If you want to send a pull request I can pull your code and credit you with the change. Else I'll add this in myself later today.

from slim.

phaseinducer avatar phaseinducer commented on May 3, 2024

I have no fork for the moment so you can make the change, yes.

from slim.

codeguy avatar codeguy commented on May 3, 2024

Pulled in, pushed to master and develop.

from slim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.