-
Notifications
You must be signed in to change notification settings - Fork 343
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
[slim3] Run xhgui in subdir #450
Conversation
Please commit with sane commit messages, so I could merge the change to intermediate branch |
// this is copy of \Slim\Slim::urlFor() | ||
// to mix path prefix in \Slim\Slim::urlFor | ||
|
||
return rtrim($this->pathPrefix(), '/') . $this->router->urlFor($name) . $query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just use $this->pathPrefix
here directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in PHP8 we have struggle to concatenate null and string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid null: $this->pathPrefix() ?: ''
src/Twig/TwigExtension.php
Outdated
@@ -132,7 +135,7 @@ public function formatPercent($value): string | |||
|
|||
private function pathPrefix(): string | |||
{ | |||
if ($this->pathPrefix !== null) { | |||
if ($this->pathPrefix !== '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no no no. this is breaking change.
null means use autodetection, having string value means use value from config.
src/Twig/TwigExtension.php
Outdated
@@ -78,7 +81,7 @@ public function url(string $name, $queryargs = []): string | |||
// this is copy of \Slim\Slim::urlFor() | |||
// to mix path prefix in \Slim\Slim::urlFor | |||
|
|||
return rtrim($this->pathPrefix(), '/') . $this->router->urlFor($name) . $query; | |||
return rtrim($this->pathPrefix, '/') . $this->router->urlFor($name) . $query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using function was correct. revert this line
I don't see what problem are you solving here. describe the problem first in PR body! |
Described in body. I changed in line 24ff the null handling to set The function |
If the detection doesn't work, you can just set path.prefix in config. also, I do not understand anything written in this comment: |
If I set path.prefix to Setting path.prefix to empty string results in: In the comment above I tried to explain what I did and why in my opinion the autodetection still works. |
Compare the html, show the rendered html tag for css. guess the problem is with leading what adds the second /xghui after the pathPrefix? |
Tested locally. having <link href="/xhgui/css/xhgui.css" rel="stylesheet" media="screen"> Using docker image provided by this project, i.e this nginx config: |
I think: If set path.prefix to null:
|
What about the link to |
this seems correct value, since you have installation at how can I reproduce your setup? also, to me it seems you want to use |
My setup has nothing special. But it uses #333. In case of Imo the main problem is in the url function that does the autodetection twice. |
Special or not. explain how to reproduce this. From description seems your current pull request doesn't fix any problem as you just set the path prefix to an empty string, so the autodetection code is never run. |
Added documentation examples how the path prefix must behave: |
I use an apache with DocumentRoot /var/www/ |
Can you make the reproducer with apache docker image? |
Further digging bring up that in /vendor/slim/slim/Slim/App.php in Line 381 the router basePath is set to I try to make it reproducibly |
Reproducing with docker image at xhgui is bind-mounted to In the container you need to disable tideways using Then you can access xhgui via The problem relates only to branch |
slim-upgrade branch is not merged, so 0.19.x and 0.20.x branches are the same |
Here's why the basepath is set on the router. I don't see it helps
|
Ok, so the problem is that same basepath added twice, made change that strips from urlFor result: That replacement PR works in docker image you provided. |
Also, please fill in meaningful commit messages if you want your changes to be merged. repeating the same commit message 5 times, isn't it. Here's some guides: |
Sorry for that. I'll try! |
A little change to be able to run xhgui with slim3 in a subdir.
I need to run xhgui on https://localhost/xhgui/.
The gui loads in general. Links work, but css and js are not found because the links are going to
/
instead of/xhgui