Closed bdbch closed 6 years ago
What exactly do you mean by "confusing Timber"? I'm guessing it isn't rendering anything? Is there an error message?
Either way, generally speaking you don't need to replace forward slashes with backslashes, since PHP should work with forward slashes irrespective of the operating system.
Yes there is an error message saying that the twig file could not be found, even though the path is correct. This is fixed as soon as I just use index.twig
without any path in front of it.
This is not only limited to Windows systems or Apache-Servers. Twigs Filesystem loader always combines the loader path with the filename. Not sure if this has been changed at some time ...
Unfortunately, there is no longer an exception thrown in newer versions of Timber, so this issue becomes very confusing, because Timber isn't rendering any component at all. It would be nice to see a merge of this pull request soon! :)
After some more digging, I found that the root cause for this error is the PHP ini setting for open_basedir, which Timber checks here: https://github.com/timber/timber/blob/master/lib/Loader.php#L138
On systems not using this setting (default is NULL), everything should work fine since the root path ('/') in the Timber loader is not modified.
Since I would rather not set the file to be fetched to just be index.twig (this file could exist in any path added to the timber/loader/paths
hook), I have made a separate PR for this fix (#265) using a relative path instead.
Awesome, no more manually fixes on project init. Good job!
Do we have an update on the PR?
Merged into master with v0.4.0
Feature
TimberLoader
Webserver Stack
System
Windows 10
Problem
I presume that Windows backslashes are confusing Timber and the TimberPaths set for loading the files. We tried using
realpath
in combination withstr_replace
to replace all forward slashes with backslashes but it didn't help fixing the problem.The only solution was to directly load the
index.twig
inside the Timber::fetch function here. Looks like on Windows Timber doesn't care about the full path but rather uses the paths defined viareturnTimberPaths
directly.Couldn't figure out a solution yet or really pinpoint down a 100% proof of what is causing this, I'll reinvestigate this, but as I said using
index.twig
instead of$filePath
here on Windows helped fixing it.