Run acorn command in PHP

Hello,
is there a way to execute Acorn commands via PHP? Something similar to Artisan’s “call” method. I tried searching but couldn’t find anything specific for Acorn.
My desired goal is to be able to execute commands like Acorn::call(‘optimize:clear’).
Thanks.

Yes, you can run Acorn commands in PHP similarly to Laravel’s Artisan::call method by using WP-CLI. Here’s a simple how to:

  1. Ensure WP-CLI and Composer are InstalledBoth are needed to run Acorn commands from PHP.
  2. Now you can simply run wp acorn optimize:clear directly from the terminal to execute Acorn commands

Let me know if you need further assistance—I’m happy to help! :blush:

I think the OP was asking about running acorn commands from theme files like views, view composers, etc.

Thank you for the reply.
Running a command from the terminal is okay.
I need to run a command from a PHP file.