Simple utility class to rename a site's database prefix. This is a modified copy of https://github.com/iandunn/wp-cli-rename-db-prefix so that it is not restricted to WP CLI usage only.
Please note this is not compatible with a multisite setup.
composer require pressmodo/database-prefixer
use Pressmodo\DB\DatabasePrefixer;
$run = ( new DatabasePrefixer( $newPrefix ) )->init();