Skip to main content

To increase the PHP memory limit for all PHP CLI (Command Line Interface) commands in Drupal, you can add a configuration to the settings.php file. Here's how to do it:

  1. Open the settings.php file for your Drupal installation. This file is usually located in the sites/default folder of your Drupal installation.

  2. Add the following lines of code to the bottom of the settings.php file:

     * Set PHP memory limit for CLI commands. 
    if (PHP_SAPI === 'cli' || ) { 
      ini_set('memory_limit', -1); 
      ini_set('max_execution_time', -1); // You can do this or change any other global variables here.

    This code checks if the current script is being executed in CLI mode by using the php_sapi_name() function. If it is being executed in CLI mode, it sets the PHP memory limit to -1 or infinite.

  3. Save the settings.php file.

Now, whenever you run a PHP CLI command, the PHP memory limit will be set to -1. You can adjust the memory limit value by changing the value passed to the ini_set() function. Instead of the PHP_SAPI php constant, you can also use the function `php_sapi_name()`.




Therefore logo
80 Atlantic Ave, Toronto, ON Canada
Call us: +1 4166405376

Let us know how we can help!