phpsword / sword-bundle

Modern WordPress development with Symfony
https://getsword.com
MIT License
124 stars 4 forks source link

Question : Can we listen and profile Wordpress events/routes in Symfony? #11

Open loicrey opened 1 year ago

loicrey commented 1 year ago

Hi.

Can we listen to WordPress events on Symfony like post creation, post updates, etc...? Additionally, will Sword will supports profiling WordPress-related routes and executions?

The project seems amazing, I'm really excited to go deeply into it and make something with it.

williarin commented 1 year ago

Hi,

WordPress is launched after Symfony's kernel.controller event, it's a fallback route with low priority. So yes you can listen to WordPress events in Symfony using WordpressService interface and adding your hooks in initialize(). You can see an example here: https://getsword.com/guide/tutorial/services.html

For the profiling unfortunately it's a bit complex to integrate it into Symfony therefore I haven't spent time on it, however you can still use QueryMonitor plugin in Wordpress.

Thanks for your interest in this project!