Skip to content

feat(env): add .wp-env.json configuration for local development envir…#500

Open
rsanchez-beapi wants to merge 4 commits into
masterfrom
feat/wp-env
Open

feat(env): add .wp-env.json configuration for local development envir…#500
rsanchez-beapi wants to merge 4 commits into
masterfrom
feat/wp-env

Conversation

@rsanchez-beapi

@rsanchez-beapi rsanchez-beapi commented Jun 25, 2026

Copy link
Copy Markdown

Ce commit introduit une configuration wp-env pour permettre aux ThemeDev de lancer rapidement un environnement WordPress local dédié au BFF, sans configuration manuelle.

Il complète cette configuration en chargeant l'autoloader Composer dans functions.php, afin que les classes PSR-4 du framework (BEA\Theme\Framework) soient disponibles dès le démarrage de l'environnement local.
Sans chargement explicite de l'autoloader et sans installation automatique des dépendances, le boot du framework échoue dans un environnement wp-env fraîchement créé.

Changements

.wp-env.json (nouveau fichier)

  • Monte le thème courant comme thème actif ("themes": [ "." ]).
  • Utilise PHP 8.3.
  • Installe automatiquement Advanced Custom Fields depuis le dépôt officiel WordPress.
  • Active les constantes de debug adaptées au développement (WP_DEBUG, WP_DEBUG_LOG, SCRIPT_DEBUG, etc.) sans afficher les erreurs à l'écran.
  • Définit WP_ENVIRONMENT_TYPE sur local et WP_DEVELOPMENT_MODE sur theme.
  • Exécute composer install automatiquement après le démarrage de l'environnement via un script afterStart.

functions.php

  • Charge conditionnellement vendor/autoload.php si la classe Framework n'est pas déjà disponible.
  • Garantit que le conteneur de services peut être initialisé correctement dans un contexte wp-env, où les dépendances Composer ne sont pas forcément présentes au moment du premier chargement du thème.

Note

Low Risk
Changes are limited to local dev configuration, optional autoload bootstrap, and Composer metadata; no production runtime or security-sensitive logic is altered.

Overview
Adds a wp-env workflow so developers can run the theme in Docker (PHP 8.3) with the repo mounted, Advanced Custom Fields wired from .wp-env/plugins/advanced-custom-fields, and an afterStart hook that activates the BFF theme and ACF.

Composer is reshaped for that setup: package type becomes wordpress-theme, wp-plugin/advanced-custom-fields is a dev dependency installed via composer/installers, WPCS is pinned to 3.3.0, and PHP 8.3 is set as the platform. composer.lock is removed from version control and ignored.

functions.php now loads vendor/autoload.php when Framework is not already autoloaded, so theme-only / wp-env installs can boot PSR-4 services after composer install.

Documentation and tooling updates: README section for wp-env (URLs, credentials, common commands, yarn start workflow), .gitignore entries for .wp-env/ and composer.lock, and PHPCS excludes .wp-env/.

Reviewed by Cursor Bugbot for commit cd1fe30. Bugbot is set up for automated code reviews on this repo. Configure here.

@rsanchez-beapi rsanchez-beapi marked this pull request as ready for review June 29, 2026 14:34
Comment thread .wp-env.json Outdated
Comment thread .wp-env.json Outdated
This change introduces Composer-based dependency management for WordPress plugins within the `wp-env` development environment.

- `composer.json` is updated to define the project as `wordpress-theme` and utilizes `installer-paths` to install plugins into `.wp-env/plugins`.
- Advanced Custom Fields (ACF) is now declared as a `require-dev` dependency and will be installed via Composer.
- The `.wp-env.json` `afterStart` script is simplified to activate the plugin, leveraging the Composer installation.
- `composer.lock` is removed and added to `.gitignore` to ensure a fresh, consistent dependency set on setup.
- The `README.md` is updated to reflect the new development environment setup.

This enhances environment consistency and provides better version control for WordPress plugin dependencies.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f4643dc. Configure here.

Comment thread .wp-env.json
Exclude the `.wp-env/` directory to prevent PHP Code Sniffer from analyzing generated or third-party WordPress core and plugin files. This avoids irrelevant warnings and errors, keeping the linting focused on project-specific code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants