Closed fiskhandlarn closed 3 years ago
Sounds bad! Have you placed a index.blade.php in "views"?
Yes, but this happens both when a index.blade.php
is present in views
and when it's not.
In Illuminate\View\Engines\PhpEngine::evaluatePath
, incoming $__path
is set to:
/uploads/.cache/8a6035cd7c5163f7ff6d7afacec04f2286173d7f.php
if I call bladerunner('index2');
in my index.php
template/themes/wordplate/index.php
if I try to call bladerunner('index');
in my index.php
templateYou don't need anything in your index.php. It has to be there as a mandatory file for WordPress. Just put a blade-file in views, eg: views/index.blade.php and fill it with a master and sections!
This problem still persists.
You don't need anything in your index.php.
Not sure if you mean theme/index.php
. If so, if I have an empty index.php
file in my theme, nothing is of course outputted.
If I have the contents as written in my first post in the index.php
file in my theme I get the same PHP error as before, irregardless if views/index.blade.php
is empty, has content or even exists at all.
Could https://github.com/ekandreas/bladerunner/issues/65#issuecomment-340720133 be a starting point for finding a solution?
Worth noting is that this happens both when I override bladerunner/template/bladepath
and when I'm not.
I think I found where this issue happens:
The findInPaths
method in vendor/illuminate/view/FileViewFinder.php
searches for index.php
and index.blade.php
in these locations:
/themes/theme
/themes/theme\views
But since index.php
exists in the first location (/themes/theme
), it stops there, tries to include it and gets stuck in an infinite loop.
A possible solution to this could be to somehow reverse the $paths
array in FileViewFinder
so that it looks in /themes/theme\views
first. Don't know if this is possible via this repo though, or if that's something that has to be done in the Illuminate repo.
Any news on this? :)
Nope, I have trouble reproducing the error. Could you please give me more information/setup?
Create index.php
in your WordPress template directory:
<?php
bladerunner('index');
Visiting the site root in the browser. I get this error:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32768 bytes) in \public\themes\project\index.php on line 1
As stated earlier, this happens both when a index.blade.php
is present in views
and when it's not.
Please let me know if I can help in clarifying this any further. :)
Have you tried the following
bladerunner('views.index');
That tells it to look in the views/ folder for the index file.
@vpillinger Then this package tries to look for views/views/index.blade.php
, which feels kind of redundant IMO. Or do you mean that it looks for views/index.blade.php
for you with that code?
@fiskhandlarn When I use bladerunner I use the following folder structure in my root theme directory
views
layouts
pages
partials
In my index.php file I call bladerunner(views.pages.index)
. It finds the view in "views/pages/index." It does not appear to search in "views/views/pages/index". Are you using the newest version? Perhaps this behavior changed at some point.
Sobladerunner('views.index')
should look in views/index.blade.php
folder.
I'm starting to understand why this is happening. Apparently this repo expects the bladerunner/template/bladepath
to be set to the parent directory of the views/
directory (thus needing to prepend the blade name with 'views.'
each time bladerunner()
is called. And I expected the path to be the actual directory where all my views are. The latter is the way Laravel does it:
<!-- Stored in resources/views/child.blade.php -->
[...]
Route::get('blade', function () {
return view('child');
});
@ekandreas If you rather keep your custom behaviour maybe the docs should be updated with a warning? :)
The example I provided for the 'bladerunner/template/bladepath'
filter should at least be updated.
Yes, the global view
command uses theme root as entrypoint. This design is made so because of usage of Bladerunner in other instances like plugin development.
bladerunner
function should be deprecated.
@ekandreas "should" or "could"? I'm not sure I understand, do you mean plugins using this package? If so, it's still redundant having to write 'views.'
in each call to bladerunner()
IMO.
Yes, if you use Laravel daily then "views" feels redundant. Just make your own path :-)
And yes, we can update the documentation. Could you please point me out where to update. The readme says theme-root-folder as starting point.
@ekandreas I'm not sure, but I think it should be clarified both under https://github.com/ekandreas/bladerunner#directories (both as a separate list item explaining that all blade files must be loaded from a sub directory, and modify "Your views must be placed within your theme folder." (which isn't really true, if by "within" you're meaning "directly in")) and as a explanation before the 'bladerunner/template/bladepath' example code under https://github.com/ekandreas/bladerunner#filters.
Hi! This is a deprecated package. Please use https://github.com/EFTEC/BladeOne instead!
If I have
index.php
in my theme with the following contents:This package chokes in
Illuminate\View\Engines\PhpEngine::evaluatePath
when that method tries to include the sameindex.php
in my theme (thus leading to a recursive loop whereindex.php
tries to include itself).