Depends on what you want to do. If you want to run the PHP code that’s behind the WP-CLI code you might consider looking at https://github.com/wp-cli/entity-command
Maybe you don’t actually need WP-CLI but the corresponding code behind it. Most WP-CLI commands have WordPress equivalents. For example of what I was trying to do today, the wp menu create "My Menu"
command is defined here:
https://github.com/wp-cli/entity-command/blob/master/src/Menu_Command.php. (It was much easier to find documentation for WP-CLI for this because 99% of results for WordPress describe how to do it via the admin panel.)
Basically it just uses the WP function:
65: $menu_id = wp_create_nav_menu( $args[0] );
So > wp menu create "My Menu"
on the commandline is roughly equivalent to wp_create_nav_menu('My Menu')
in a functions.php
file.
Similarly, the plugin command would be addressed as a WP-CLI extension command defined in Plugin_Command.php which uses the WordPress command activate_plugin(). If you want to know the WP version of the WP-CLI command you could look it up yourself or include the specific command you want to know in your question.