@@ -10,7 +10,7 @@ Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contr
1010## Using
1111
1212~~~
13- wp shell [--basic] [--hook=<hook>]
13+ wp shell [--basic] [--watch=<path>] [-- hook=<hook>]
1414~~~
1515
1616` wp shell ` allows you to evaluate PHP statements and expressions
@@ -19,12 +19,21 @@ hit enter, and see the code execute right before you. Because WordPress
1919is loaded, you have access to all the functions, classes and globals
2020that you can use within a WordPress plugin, for example.
2121
22+ The ` restart ` command reloads the shell by spawning a new PHP process,
23+ allowing modified code to be fully reloaded. Note that this requires
24+ the ` pcntl_exec() ` function. If not available, the shell restarts
25+ in-process, which resets variables but doesn't reload PHP files.
26+
2227** OPTIONS**
2328
2429 [--basic]
2530 Force the use of WP-CLI's built-in PHP REPL, even if the Boris or
2631 PsySH PHP REPLs are available.
2732
33+ [--watch=<path>]
34+ Watch a file or directory for changes and automatically restart the shell.
35+ Only works with the built-in REPL (--basic).
36+
2837 [--hook=<hook>]
2938 Ensure that a specific WordPress action hook has fired before starting the shell.
3039 This validates that the preconditions associated with that hook are met.
@@ -40,6 +49,18 @@ that you can use within a WordPress plugin, for example.
4049 wp> get_bloginfo( 'name' );
4150 => string(6) "WP-CLI"
4251
52+ # Restart the shell to reload code changes.
53+ $ wp shell
54+ wp> restart
55+ Restarting shell in new process...
56+ wp>
57+
58+ # Watch a directory for changes and auto-restart.
59+ $ wp shell --watch=wp-content/plugins/my-plugin
60+ wp> // Make changes to files in the plugin directory
61+ Detected changes in wp-content/plugins/my-plugin, restarting shell...
62+ wp>
63+
4364 # Start a shell, ensuring the 'init' hook has already fired.
4465 $ wp shell --hook=init
4566
0 commit comments