Call to undefined method Roots\Acorn\Bootloader::getApplication()
braco opened this issue · 17 comments
Hey, just tried your theme out, it errors for me on this line:
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-hook.php#L308
and
/app/wordpress/vendor/roots/acorn/src/Roots/helpers.php:57
\Roots\add_actions(['after_setup_theme', 'rest_api_init'], function () use ($bootloader) {
$app = $bootloader->getApplication();
if ($app->hasBeenBootstrapped()) { return; }
@braco: For reproducing the error you submitted, I just cloned this theme repository without any changes and put into a WordPress/Bedrock development environment, and everything works fine out of the box.
Are you just using this sample theme without any changes?
- What PHP version are you using?
(It should currently work with7.4
;8.0
and8.1
(slightly older upstream version that still has PHP7.4
support)). - Have you used
composer update
instead ofcomposer install
on the theme?
Although this should not happen (in an ideal world...), this may cause incompatible package versions to be installed,
especially after the recent newacorn
release (and breaking changes to older Sage 10 files). - What WordPress version is used with the theme, the latest one?
- Is the Gutenberg plugin used (not necessary, but helps with troubleshooting)?
- Was
composer install
invoked in the theme directory? - What additional plugins are used?
- Does it work when you disable all plugins (except the Gutenberg, if used)?
Hey @strarsis, thanks for the reply. This is the base theme with no modifications. Notably, the core Sage theme doesn't throw any errors.
- PHP 8.1
- I don't think so, but what would be the fix for this, or how is it diagnosed?
- WP 6.1.1
- No
- did this again, "Nothing to install, update or remove"
- disabled all plugins
- no
@braco: You can check out the original files:
git checkout composer.json
; git checkout composer.lock
and then composer install
.
Is your PHP CLI also version 8.1
?
I wiped everything and did a checkout again, same problem.
PHP CLI is the same version yes.
Just re-verified that Sage 10.5.1 works, looks like you're a few versions behind?
Any other ideas?
Just re-verified that Sage 10.5.1 works, looks like you're a few versions behind?
Yes, this version is slightly older, still supporting PHP 7.x.
Hm, I would have to update it and then it should work.
Just out of curiosity: I haven't used PHP in a decade, and this is my first Sage project – why does it seem like these Sage extension projects have to copy the entire repo instead of providing a plugin?
@braco: In this case this is not a plugin, but a modified Sage theme. It also requires an acorn
package as dependency that was slightly modified, so that it is compatible with Gutenberg Full Site Editing template loading. It also ships with concrete examples for block templates, patterns, parts and so on.
So you could just create a new Sage 10 theme and then apply the FSE-specific modifications on top of it.
I have to do the same for this sample repository, I have to update it to the latest Sage and merge/apply the modifications for FSE.
got it, and it's hard to modularly extend Sage (sage plugins?) in a way that's durable between updates? I'm just starting to wade in to the development and surprised by the lack of full examples in the ecosystem.
@braco: I updated the underlying Sage 10 to latest version, also an updated acorn
patch is used for proper loading of the FSE templates. It should also work now in your case with PHP 8.1.
@braco: When you got time to test this, let me know whether your issue still persists.
Hi! @strarsis Is there a chance to use sage 10 hybrid with FSE? I'm trying to get the effect that FSE templates are overwritten by blade template.
I think I figured out if we can use instead:
public function filterTemplateHierarchy($files) { return $files + [$this->sageFinder->locate($files)]; }
to this:
public function filterTemplateHierarchy($files) { return array_merge($this->sageFinder->locate($files), $files); }
on acorn FiltersTemplates.php
@r-chrzan: When this preserves the existing FSE-compatibility, I would replace that line in the acorn
patch.
Blade-PHP hybrid theme support would be nice of course.
@strarsis I'm currently setting up an e-commerce + FSE project, so it's a good time to test it out. I'll let you know if all the templates work properly. And if I run into problems, I'll share it here.
@r-chrzan: You may find this example interesting for WooCommerce Gutenberg blocks:
woocommerce/woocommerce-blocks#891 (comment)