Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ assets/conf-img/*.json
### theme.json
src/scss/01-abstract/_theme-json.scss
theme.json

### wp-env
.wp-env/

### Composer
composer.lock
23 changes: 23 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"phpVersion": "8.3",
"testsEnvironment": false,
"themes": [
"."
],
"plugins": [
".wp-env/plugins/advanced-custom-fields"
],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": false,
"SCRIPT_DEBUG": true,
"WP_ENVIRONMENT_TYPE": "local",
"WP_DEVELOPMENT_MODE": "theme"
},
"lifecycleScripts": {
"afterStart": "wp-env run cli wp theme activate beapi-frontend-framework && wp-env run cli wp plugin activate advanced-custom-fields"
Comment thread
firestar300 marked this conversation as resolved.
}
}
81 changes: 80 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,85 @@ Alternatively, you can use NPM.
npm install
```

## Local development with wp-env

BFF ships with a [wp-env](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/) configuration (`.wp-env.json`) to run a local WordPress instance with Docker.

### Requirements

- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or a compatible Docker runtime)
- Node.js (see [Requirements](#nodejs))

### Installing wp-env

You can run wp-env without a global install via `npx @wordpress/env`, or install the CLI once and use the `wp-env` command:

```bash
# Global install (npm or yarn)
npm install -g @wordpress/env
# or
yarn global add @wordpress/env
```

After installation, replace `npx @wordpress/env` with `wp-env` in the commands below.

### Getting started

From the theme root:

```bash
yarn
npx @wordpress/env start
# or, if wp-env is installed globally:
wp-env start
```

On first start, wp-env will:

- Spin up WordPress (PHP 8.3)
- Mount this theme from the current directory
- Install and activate the [Advanced Custom Fields](https://wordpress.org/plugins/advanced-custom-fields/) plugin

### URLs and credentials

| | |
|---|---|
| Site | http://localhost:8888 |
| Admin | http://localhost:8888/wp-admin |
| Username | `admin` |
| Password | `password` |

### Common commands

```bash
# Start the environment
npx @wordpress/env start # or: wp-env start

# Stop containers (data is preserved)
npx @wordpress/env stop # or: wp-env stop

# Remove containers and volumes
npx @wordpress/env destroy # or: wp-env destroy

# Run WP-CLI inside the environment
npx @wordpress/env run cli wp plugin list
# or: wp-env run cli wp plugin list

# Run a command in the theme directory
npx @wordpress/env run cli --env-cwd=wp-content/themes/beapi-frontend-framework composer install
# or: wp-env run cli --env-cwd=wp-content/themes/beapi-frontend-framework composer install
```

### Development workflow

With wp-env running, start the Webpack watcher in a second terminal:

```bash
yarn start
```

Changes to PHP, SCSS, and JavaScript assets are reflected after Webpack rebuilds. Theme PHP changes are picked up immediately thanks to the mounted volume.

## Configuration

The configurations files are in `config` directory.
Expand Down Expand Up @@ -130,4 +209,4 @@ function customize_editor_settings( $settings ) {

return $settings;
}
```
```
27 changes: 23 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
{
"name": "beapi/beapi-frontend-framework",
"description": "Frontend Framework theme for WordPress",
"type": "metapackage",
"type": "wordpress-theme",
"extra": {
"installer-paths": {
".wp-env/plugins/{$name}/": [
"type:wordpress-plugin"
]
}
},
"repositories": [
{
"name": "wp-packages",
"type": "composer",
"url": "https://repo.wp-packages.org"
}
],
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"overtrue/phplint": "^9.0",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpro/grumphp-shim": "^2.6",
"roave/security-advisories": "dev-latest",
"wp-coding-standards/wpcs": "^3.1"
"wp-coding-standards/wpcs": "3.3.0",
"wp-plugin/advanced-custom-fields": "6.8.4"
},
"scripts": {
"scripts": {
"cs": [
"./vendor/bin/phpcs ."
],
Expand All @@ -27,7 +42,11 @@
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpro/grumphp-shim": true
"phpro/grumphp-shim": true,
"composer/installers": true
},
"platform": {
"php": "8.3.0"
}
}
}
Loading
Loading