How to enable (install) a module programmatically in Drupal 8
A big change in Drupal 8 is that you can no longer enable and disable modules. You can only install and uninstall. The difference is paramount.
In Drupal 7 if you disabled a module and then enabled it back, you retained the modules settings all data stored by that module. This is not longer the case with Drupal 8. Uninstalling means completely removing all data and settings added to the module when it was installed. So please, be careful :)
How to install a module programmatically? Check below:
Lets install Admin Toolbar. A nice handy module extending the Drupal default toolbar.