How do I define an external URL in settings.php and call it in a custom module? In the settings.php file, there are (for example) $base_url, $settings['hash_salt']. 

I defined $settings['external_url'] = "google.com";

In my custom module, I want to get the $settings['external_url'] value.

&lt;?php

namespace Drupal\my_custom_module\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Site\Settings;
use Drupal\Core\Form\FormStateInterface;

/**
* Contribute form.
*/
class MyCustomClass extends FormBase {

   private $base_url;
   public function __construct(){
       $this-&gt;base_url = Settings::get('external_url') . '/maps';

   }

   public function validateForm(array &amp;$form, FormStateInterface $form_state) {
      $pb= $form_state-&gt;getValue('pb');
      $url = $this-&gt;base_url . '?timeline' . $pb;
   }
}


Then I got this error:

Notice: Trying to get property of non-object

I am using Drupal 8 and PHP 7.
Trying using the full path of the class:

\Drupal\Core\Site\Settings::get('external_url')


In Drupal 8, an ideal place for custom variables is in config files. Create a yml file in the config directory and import the configuration.

my_variables.settings.yml

external_url: 'url-string-here'


Then to fetch the values, it's: 

\Drupal::config('my_variables.settings')-&gt;get('external_url')


https://www.drupal.org/docs/8/converting-drupal-7-modules-to-drupal-8/step-4-convert-drupal-7-variables-to-drupal-8