Title: PHP Error on wpCLI &#8211; WP Engine Hosted
Last modified: December 9, 2020

---

# PHP Error on wpCLI – WP Engine Hosted

 *  Resolved [dabricksz](https://wordpress.org/support/users/dabricksz/)
 * (@dabricksz)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/)
 * when running wp command on wpcli I receive the following error:
 *     ```
       PHP Warning:  fopen(/sites/mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 325
       Warning: fopen(/sites/mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 325
       PHP Warning:  flock() expects parameter 1 to be resource, bool given in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 326
       Warning: flock() expects parameter 1 to be resource, bool given in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 326
       PHP Warning:  include(/sites/mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       Warning: include(/sites/mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       PHP Warning:  include(): Failed opening '/sites/mywebsite.com/wp-content/wflogs/rules.php' for inclusion (include_path='.:/usr/share/php:/sites/mywebsite.com/wp-content/plugins/myworks-woo-sync-for-quickbooks-online/includes/lib/quickbooks-lib') in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       Warning: include(): Failed opening '/sites/mywebsite.com/wp-content/wflogs/rules.php' for inclusion (include_path='.:/usr/share/php:/sites/mywebsite.com/wp-content/plugins/myworks-woo-sync-for-quickbooks-online/includes/lib/quickbooks-lib') in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       PHP Warning:  flock() expects parameter 1 to be resource, bool given in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 329
       Warning: flock() expects parameter 1 to be resource, bool given in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 329
       PHP Warning:  fclose() expects parameter 1 to be resource, bool given in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 330
       Warning: fclose() expects parameter 1 to be resource, bool given in /sites/mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 330
       ```
   
 * – One thing that stands out to me is this:
 * > “(include_path=’.:/usr/share/php:/sites/mywebsite.com/wp-content/plugins/myworks-
   > woo-sync-for-quickbooks-online/includes/lib/quickbooks-lib’)”
 * /usr/share/php is not something I have access to.
 * I’m worried that the firewall is not properly functioning, as there have been
   no recorded IP or country blocks recently. Please help.

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [WFAdam](https://wordpress.org/support/users/wfadam/)
 * (@wfadam)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13773049)
 * Hello [@dabricksz](https://wordpress.org/support/users/dabricksz/) and thanks
   for reaching out to us!
 * Can you send a diagnostic report to **wftest @ wordfence . com**? You can find
   the link to do so at the top of the **Wordfence Tools > Diagnostics** page. Then
   click on **“Send Report by Email”**. Please add your forum username where indicated
   and _respond here after you have sent it._
 * Thanks!
 *  Thread Starter [dabricksz](https://wordpress.org/support/users/dabricksz/)
 * (@dabricksz)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13773246)
 * Thanks for responding! [@wfadam](https://wordpress.org/support/users/wfadam/)
 * As requested, I have sent the diagnostic report.
 *  Plugin Support [WFAdam](https://wordpress.org/support/users/wfadam/)
 * (@wfadam)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13773423)
 * Thanks for sending that report [@dabricksz](https://wordpress.org/support/users/dabricksz/)
 * It looks like these errors are trying to access the `wflogs` folder but the diagnostic
   says you’re using **MySQLi** so that `wflogs` folder is stored in the database
   instead of the file system.
 * We might need to tell Wordfence to store the contents of `wflogs/*` in the database
   instead
 * You can do this by editing `wordfence-waf.php` and adding `define('WFWAF_STORAGE_ENGINE','
   mysqli');` right after `<?php` on a new line.
 * [https://www.wordfence.com/help/firewall/mysqli-storage-engine/](https://www.wordfence.com/help/firewall/mysqli-storage-engine/)
 * Let me know if this helps!
 * Thanks!
 *  Thread Starter [dabricksz](https://wordpress.org/support/users/dabricksz/)
 * (@dabricksz)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13773807)
 * [@wfadam](https://wordpress.org/support/users/wfadam/) I have tried all the initial
   troubleshooting instructions.
 * I first tried adding the line to wordfence-waf.php on my production env.
    I then
   tried to add it to wp-config.php also on production env.
 * neither worked.
 * I then tried deleting wflogs directory on my staging copy, however i still received
   the same errors.
 * Here is command line response for these troubleshooting options:
 *     ```
       $ cat wordfence-waf.php
       <?php
       define('WFWAF_STORAGE_ENGINE', 'mysqli');
       // Before removing this file, please verify the PHP ini setting <code>auto_prepend_file</code> does not point to this.
       if (file_exists('/nas/content/live/staging.mywebsite.com/wp-content/plugins/wordfence/waf/bootstrap.php')) {
               define("WFWAF_LOG_PATH", '/nas/content/live/staging.mywebsite.com/wp-content/wflogs/');
               include_once '/nas/content/live/staging.mywebsite.com/wp-content/plugins/wordfence/waf/bootstrap.php';
       }
       ?>
   
       $ ls wp-content/wflofgs
       ls: cannot access 'wp-content/wflofgs': No such file or directory
   
       $ wp
       PHP Warning:  fopen(/sites/staging.mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 325
       Warning: fopen(/sites/staging.mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 325
       PHP Warning:  flock() expects parameter 1 to be resource, bool given in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 326
       Warning: flock() expects parameter 1 to be resource, bool given in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 326
       PHP Warning:  include(/sites/staging.mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       Warning: include(/sites/staging.mywebsite.com/wp-content/wflogs/rules.php): failed to open stream: No such file or directory in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       PHP Warning:  include(): Failed opening '/sites/staging.mywebsite.com/wp-content/wflogs/rules.php' for inclusion (include_path='.:/usr/share/php:/sites/staging.mywebsite.com/wp-content/plugins/myworks-woo-sync-for-quickbooks-online/includes/lib/quickbooks-lib') in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       Warning: include(): Failed opening '/sites/staging.mywebsite.com/wp-content/wflogs/rules.php' for inclusion (include_path='.:/usr/share/php:/sites/staging.mywebsite.com/wp-content/plugins/myworks-woo-sync-for-quickbooks-online/includes/lib/quickbooks-lib') in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 328
       PHP Warning:  flock() expects parameter 1 to be resource, bool given in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 329
       Warning: flock() expects parameter 1 to be resource, bool given in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 329
       PHP Warning:  fclose() expects parameter 1 to be resource, bool given in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 330
       Warning: fclose() expects parameter 1 to be resource, bool given in /sites/staging.mywebsite.com/wp-content/plugins/wordfence/vendor/wordfence/wf-waf/src/lib/waf.php on line 330
       ```
   
 * this did not resolve the issue as shown. The php error still pops up and I’m 
   still not seeing any ip or country blocks
 *  Plugin Support [WFAdam](https://wordpress.org/support/users/wfadam/)
 * (@wfadam)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13786994)
 * Thanks for sending that over!
 * Could you email me your `wordfence-waf.php` file and your `user.ini`? I want 
   to review the contents to see what might be happening. wftest @ wordfence . com
   and put your username as the subject.
 * It also looks like the auto_prepend_file is being used by your host and is not
   pointed at the wordfence-waf.php correctly. wordfence-waf is being prepended 
   only on the CLI and not on web requests.
 * Thanks!
 *  Thread Starter [dabricksz](https://wordpress.org/support/users/dabricksz/)
 * (@dabricksz)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13788948)
 * [@wfadam](https://wordpress.org/support/users/wfadam/) contents of those files
   were sent as requested. Thanks for getting back to me.
 *  Thread Starter [dabricksz](https://wordpress.org/support/users/dabricksz/)
 * (@dabricksz)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13799500)
 * [@wfadam](https://wordpress.org/support/users/wfadam/) anything on this?
 *  We had to enable another WAF for the time being in order to stay pci compliant…
   unfortunately There was no indication that the plugin did not function properly.
   
   It would be great if there was some sort of indicator that shows the plugin was
   only functioning on my php-cli, but not on the server instance. ESPECIALLY being
   that pci compliance requires having a WAF active.
 * The only reason I even knew something was wrong was because I was using wpcli,
   which most users will never do, so to me this is concerning.
 * I understand it can be some sort of configuration issue related to my hosting,
   so I’m not blaming Wordfence in any way. Its a free plugin and works in most 
   scenarios. I appreciate the work put in to make this the top WAF for WordPress.
 *  I was going to purchase a premium version as well, but have to hold off as the
   plugin is not functioning on my site, and cant justify paying for something that
   doesn’t currently work for us. I hope we can resolve this, so I can proceed with
   a premium plan.
 * Thanks.
 *  Plugin Support [WFAdam](https://wordpress.org/support/users/wfadam/)
 * (@wfadam)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13808781)
 * Sorry about the delay [@dabricksz](https://wordpress.org/support/users/dabricksz/)
 * Thanks for sending that information over. I think I have found where the issue
   might be stemming from.
 * If you look at your `user.ini` you sent me, note the path to your `wordfence-
   waf.php` file that `auto_prepend_file` is pointed at. Now look at your diagnostic
   in the Wordfence Firewall section. It has a different path listed for your `wordfence-
   waf.php` file. So something isn’t set correctly and I think it might be a PHP
   variable possibly being set by your host.
 * Reach out to them and ask:
    “I need to set an auto_prepend_file to point at the
   wordfence-waf.php file but something is preventing the correct path.”
 * Let me know what they say to try.
 * Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘PHP Error on wpCLI – WP Engine Hosted’ is closed to new replies.

 * ![](https://ps.w.org/wordfence/assets/icon.svg?rev=2070865)
 * [Wordfence Security - Firewall, Malware Scan, and Login Security](https://wordpress.org/plugins/wordfence/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordfence/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordfence/)
 * [Active Topics](https://wordpress.org/support/plugin/wordfence/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordfence/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordfence/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [wpcli](https://wordpress.org/support/topic-tag/wpcli/)
 * [wpengine](https://wordpress.org/support/topic-tag/wpengine/)

 * 8 replies
 * 2 participants
 * Last reply from: [WFAdam](https://wordpress.org/support/users/wfadam/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/php-error-on-wpcli-wp-engine-hosted/#post-13808781)
 * Status: resolved