metabolism / wordpress-bundle

Use Wordpress and Symfony together using a Symfony bundle
MIT License
59 stars 17 forks source link

Configuration of the wp-admin path / preventing multiple reads from composer.json #35

Closed markeasting closed 11 months ago

markeasting commented 11 months ago

1) The WordPress admin path is currently hard-coded to public/edition/:

https://github.com/jerome-barbato/wordpress-bundle/blob/c74a9740816164b6f2239e7e0a8e1cf21ca1179f/src/Loader/ConfigLoader.php#L37-L39

Wouldn't it be a good idea to make this configurable, e.g. via the .env file?

2) If the admin path is moved, the bundle will read the composer.json file (twice...!) Here's the first:

https://github.com/jerome-barbato/wordpress-bundle/blob/c74a9740816164b6f2239e7e0a8e1cf21ca1179f/src/Loader/ConfigLoader.php#L41-L43

And then again in WordpressBundle:

https://github.com/jerome-barbato/wordpress-bundle/blob/c74a9740816164b6f2239e7e0a8e1cf21ca1179f/src/WordpressBundle.php#L113-L116

This feels like it's quite inefficient - the program is reading and json_decoding the composer file twice, just to get the wp-admin path.

I have to say, I like that the bundle looks for the composer config, which reduces code duplication in the path configuration. Maybe this config step can be configured during the first load, and then cached using the Symfony memory/filesystem cache?

jerome-barbato commented 11 months ago

Hello @markeasting , thank you for your feedback, you are right, there was also an error in the path "pubic" vs "public" forcing the load of the composer file... I've made a commit https://github.com/jerome-barbato/wordpress-bundle/commit/72931e19dbbe10cb64eb7b044fce4694abaa4dec with a new PathHelper class to resolve Wordpress Root folder, env variable "WP_PATH" is used if set, with a fallback hard coded. If all failed, It will search in the composer file.

jerome-barbato commented 11 months ago

Released in 2.2.0