Configure git to ignore some files locally without .gitignore file

Some times you dont want to add something to .gitignore, while it would be nice that there is some .gitignore-local version by default, there is not, so you need to find a different way to do this, the way to do is this.  Go to .git/info/exclude file and edit it like regular .gitignore file, add files/folders you want to ignore.

Xdebug and docker4drupal on mac

To have xdebug working, you need to have this in your docker config for PHP.

      PHP_XDEBUG: 1
      PHP_XDEBUG_DEFAULT_ENABLE: 1
      PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
      PHP_XDEBUG_REMOTE_HOST: 10.254.254.254 # macOS, Docker < 18.03

Also it is often noted that this should also be run

Making url with anchor(fragment) and making url with query string appended

$options = ['fragment' => 'feedback'];
$url = Url::fromRoute('entity.node.canonical', ['node' => 22], $options);

$options = ['query' => ['animal' => 'dog', 'color' => 'black']];
$url = Url::fromRoute('entity.node.canonical', ['node' => 42], $options);

So first would give you  this result 

Some ways to make links in drupal 8

// Link to an internal path defined by a route.
$link = Link::createFromRoute('This is some link', 'entity.node.canonical', ['node' => 22])

// Link to an external URI.
$link = Link::fromTextAndUrl('This is a link', Url::fromUri('https://example.com'));

// Get output as a render array.
$link->toRenderable();

// Get output as a string.

How to create URL's from internal route or external URI

// From a route.
$url = Url::fromRoute('contact.site_page');
// From a URI.
$url = Url::fromUri('https://example.com');
// From route with additional parameters.
$url = Url::fromRoute('entity.node.canonical', ['node' => 22]);

 

How to put form in a block programmaticaly

Putting some form in a block is matter of creating a new block and assigning a form to it through form_builder that is called through dependency injection(DI) and then using method getForm that will get rendered array of this form, which is exactly what build method for block expects to output