Development

Increasing Memory for Specific Paths in Drupal 8

Most of the examples I see for Drupal 8 are for single-path memory limit increases.

The examples for Drupal 7 often follow the pattern below.

Here’s a D8 version that supports multiple paths.

Place this in your settings.php (or site/environment-specific settings.php), then update the paths accordingly.

The options are endless for how you can handle different paths. Here’s another example where we cover node/{NID}/edit  paths.

You could combine the node/add  and node/{NID}/edit  paths with the same regex pattern.

You could handle all of the urls with preg_match  if that’s your preference. strpos  is more performant, as far as I know.

One Comment

  • John C

    Thank you. This code is so useful. I will use it to increase memory limit for the user upload page and checkout page of my website. Some people had their files not uploaded on those pages before.

Leave a Reply

Your email address will not be published.