Drupal 8 uses Composer for package dependencies and autoloading
classes based on PSR standards. This allows us to use any available PHP library much more easily than in previous versions of Drupal.
In this recipe, we will add the IpRestrict Stack Middleware
library to add the functionality to whitelist access to the Drupal site based on allowed IP addresses.
You need to have Composer installed in order to use the Composer manager workflow. You can follow the Getting Started documentation at https://getcomposer.org/doc/00-intro.md. We will add the alsar/stack-ip-restrict
library as a dependency to our Drupal installation.
- Using your terminal, navigate to your Drupal site's root directory.
- Use the
require
command from Composer to add the library:
composer require alsar/stack-ip-restrict
- Composer will then add the library to the
composer.json
file and install the library along with any dependencies. Its namespace will now...