ekino / EkinoWordpressBundle

Integrate Symfony with WordPress and WordPress with Symfony
GNU General Public License v2.0
311 stars 79 forks source link

UndefinedFunctionException in ThemeExtension.php line 50 #130

Open spras opened 7 years ago

spras commented 7 years ago

Sorry,

But i didn't manage to include WP header in my twig template as it might be donne by adding {{ wp_get_header() }}

I have this error

UndefinedFunctionException in ThemeExtension.php line 50:
Attempted to call function "get_header" from the global namespace.
in ThemeExtension.php line 50
at ThemeExtension->getHeader() in 19f64244d06a93a0820abd0e8c807b7eb5e4818eaa365f1f228aebef615ba1ea.php line 50
at __TwigTemplate_d5e711f86a4a701ad023e0e021a5e9cd0e340f444811e1cc937ce5439aa98718->block_body(array('base_dir' => 

I think i missed something but i don't see what ?

wordpress/wp-includes/general_template.php where get_header() function is, is not loaded when i display my symfony page.

Do i need the wordpress eiko plugin ? if yes it's not clearly specified in documentation.

Thank's

mickoz commented 7 years ago

I am currently testing this Bundle and I hit the same problem and think I found the root cause. My best hypothesis is we copied this part of the EkinoWordPressBundle's Installation instruction into our app/config.yml:

ekino_wordpress:
    ...
    enable_wordpress_listener: false # If you want to disable the WordPress request listener
    ...

Comment/Remove the line (or set it to true which is the default value) and the bundle will load WordPress files, and the WordPress's function get_header() will then be available. If you set it to false, as said in the comment, it will skip loading WordPress into Symfony.

The way it is said, it was not as obvious to me too, and we may want to improve the documentation of this Bundle on a couple of details. If I end up using it and loving it, I am currently taking notes, and will see if I can help improve that part later on... as there is a lot of little quirks I'm hitting that does make it work "super easily" out of the box and have to figure out. My little experience with the Symfony full-stack framework and all its components might not help as I mostly used some components independently there and there in other projects in my past, and currently learning the full-stack. Still I wish the installation instructions would make this Bundle works easily and explain to the user the options a bit better, the good news with open source project is we can contribute to improve it!).