Closed erip2 closed 2 years ago
It is a function naming clash, this package is loaded before the theme is loaded and thus the app() function is registered and then Sage is no longer registering another one.
Thanks for your response @filipac. Do you suggest any solution?
I'm not a PHP developer, I'm more on the front-end and that's why I haven't been able to find even a half solution for this.
@erip2 What worked for me is to go in wp-content/plugins/spatie-ray/vendor/autoload.php
and comment out the app
function definition.
Of course this will break again if the plugin is updated, but commenting out again makes it work.
Oh, cool man, that worked. You probably will save me hours of debugging, so thanks for that!
Closing this issue as is not related to only Ray, I don't know if it's an implementation issue, but it's not for me to say.
Describe the bug
I'm using Sage 10 to develop a WordPress theme: https://docs.roots.io/sage/10.x/installation/
After I install and activate the Ray plugin, I get this error:
Fatal error: Uncaught Error: Call to undefined function Spatie\WordPressRay\app() in /Users/eripanci/Documents/project-sage/dev/public/app/plugins/spatie-ray/vendor/autoload.php:110 Stack trace: #0 /Users/eripanci/Documents/project-sage/dev/public/app/themes/project-sage/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(592): app() #1 /Users/eripanci/Documents/project-sage/dev/public/app/themes/galia-sage/config/assets.php(37): public_path('manifest.json') #2 /Users/eripanci/Documents/project-sage/dev/public/app/themes/galia-sage/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(72): require('/Users/eripanci...') #3 /Users/eripanci/Documents/project-sage/dev/public/app/themes/galia-sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/LoadConfiguration.php(36): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Roots\Acorn\Application), Object(Illuminate\Config\Repository)) #4 /Users/eripanci/Documents/project-sage/dev/public/app/themes/galia-sage/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(237): Roots\Acorn\Bootstrap\LoadConfiguration->bootstrap(Object(Roots\Acorn\Application)) #5 /Users/eripanci/Documents/project-sage/dev/public/app/themes/galia-sage/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(208): Illuminate\Foundation\Application->bootstrapWith(Array) #6 /Users/eripanci/Documents/project-sage/dev/public/app/themes/galia-sage/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(181): Roots\Acorn\Bootloader->app() #7 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-includes/class-wp-hook.php(303): Roots\Acorn\Bootloader->__invoke('') #8 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, Array) #9 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-includes/plugin.php(470): WP_Hook->do_action(Array) #10 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-settings.php(556): do_action('after_setup_the...') #11 /Users/eripanci/Documents/project-sage/dev/public/wp-config.php(15): require_once('/Users/eripanci...') #12 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-load.php(55): require_once('/Users/eripanci...') #13 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-admin/admin.php(34): require_once('/Users/eripanci...') #14 /Users/eripanci/Documents/project-sage/dev/public/cms/wp-admin/index.php(10): require_once('/Users/eripanci...') #15 /Users/eripanci/.composer/vendor/laravel/valet/server.php(235): require('/Users/eripanci...') #16 {main} thrown in /Users/eripanci/Documents/project-sage/dev/public/app/plugins/spatie-ray/vendor/autoload.php on line 110
It may have to do with the Sage own "app" function: https://github.com/roots/acorn/blob/main/src/Roots/helpers.php#L75
Versions Ray plugin: 1.5.1 Wordpress: 5.8.3 Sage: 10.0.0-beta.2
To Reproduce Steps to reproduce the behavior:
Create a new theme using Sage command line and install the Ray plugin.