Drupal 8

Programmatically install / uninstall module - Drupal 8

Modules are used to extend and customize Drupal Core. To install module normally we can navigate to "Admin => Extend" link in toolbar.

Like older versions of Drupal, Drupal 8 doesn't allow modules to be enable / disable. The only thing we can do is either install a module or completely uninstall it.

Below example shows how to install module using code:

Redirect User after login - Drupal 8

When building sites, many client wants users to get redirected to particular page (like Site Home Page) or page based on User Roles. Today we'll see how we can redirect user after login to particular page.

NOTE: I've defined my own custom page using [MODULENAME].routing.yml named as "custom.redirect_callback", which we'll be using for redirecting user.