19 votes
Accepted

Problem installing in local "The translation server is offline"

I think you didn't select English in the first step, and probably your Internet connection is behind a proxy and I guess Drupal doesn't support it. You can select English and continue or: Go to ...
  • 3,541
19 votes
Accepted

How do I create a role programmatically?

The problem is in the data array change name by label: $role = \Drupal\user\Entity\Role::create(array('id' => 'client', 'label' => 'Client')); $role->save(); Or you can use: //your data ...
17 votes
Accepted

Cannot install any theme

This is an nginx configuration issue and discussed intensely on this page Yet curiously no solid solution could be offered. Some guy on an other page proposed a solution. I applied that proposed ...
16 votes
Accepted

Installation error with Composer

Please make sure your webserver (nginx/apache) is using the same PHP version as your cli one. For example, you may encounter this issue if your cli PHP version is PHP 7.1 and your webserver is using ...
  • 628
16 votes
Accepted

Notice: Trying to access array offset on value of type null in while installing drupal

I suspect you are installing Drupal (or at least trying to) on a server running PHP 7.4, which is not currently compatible with the latest version of Drupal (8.8). There is an issue on drupal.org ...
15 votes

Does drush need to be installed as root?

NOTE The issue described in the Question has now be fixed in the latest Drush version. No, Drush does not need to be installed as root. I've submitted Drush pull #2246 to update the current Drush ...
14 votes

Drush CC all returning "No Drupal site found, only 'drush' cache was cleared"

There are a few things you can do to help debug your drush. Here is what you can try: Debug output Use drush cc all -vvv This will provide you with some valuable information in terms of what Drush ...
14 votes
Accepted

Error when attempting to create sync directory

Nothing wrong with that. It is recommend to have the config folder outside of the public web folder; Drupal just doesn't have that. To keep the installation simple for non-experienced users, it puts ...
  • 81.7k
11 votes
Accepted

How to install with composer external library that drupal module depends on

You should be able to include this package via composer by adding some repository info. Add a package definition to your repositories section in your composer.json. The resulting repositories section ...
  • 7,222
10 votes
Accepted

Best way to delete all variables when uninstalling module

Variables are cached, so deleting manually is fine so long as you invalidate that cache, e.g. db_delete('variable') ->condition('name', 'mymodule_%', 'LIKE') ->execute(); cache_clear_all('...
  • 164k
10 votes
Accepted

Parse error: syntax error, unexpected '[', expecting ')' in C:\xampp\htdocs\drupal-8\core\vendor\react\promise\src\functions.php on line 62

Drupal 8 requires PHP 5.5.9 or higher (for short array syntax among other things). You'll need to upgrade your version of PHP. Source: System Requirements
  • 164k
9 votes
Accepted

Why does Drupal say I need to upgrade to 8.0.0 beta 6 when I'm already checked out on that tag?

update.module doesn't know about git. It only understands .info(.yml in D8) files. And .info.yml files only get their version as part of the package building process. If you look at your system.info....
  • 81.7k
9 votes
Accepted

How to fix error 'This site can’t be reached' for a site installed on Amazon?

It's because by default port 22 (SSH) comes open in your EC2 security group, but port 80 (HTTP) is not open. You need to edit your security group. To get there, in your EC2 list, scroll all the way ...
  • 29.8k
9 votes
Accepted

How to set the default theme programmatically

The current advice is to set this via config: \Drupal::configFactory() ->getEditable('system.theme') ->set('default', $theme) ->save(); The previous method using ThemeHandlerInterface:...
  • 164k
8 votes

How to get list of module folders which can be deleted safely?

Use this: drush pmi --fields=type,project,title,status,path --format=table|sort This gives you a module list with five columns: First is the type of project: module or theme. Second one is the ...
  • 6,926
8 votes

Does hook_install() get called before or after configuration yml files are loaded?

When Drupal install a module, first it installs the default configuration of the module, then it invokes its hook_install(). This is evident from ModuleInstaller::install(), which contains the ...
  • 95k
8 votes
Accepted

How to recreate the user_picture field?

Instead of importing configuration as suggested previously, you could as an alternative, programmatically re-create the field. Here is some code that does that. <?php use Drupal\field\Entity\...
7 votes
Accepted

Truncate tables before uninstalling a module in Drupal 8

That's a known issue right now. There's no way right now to hook into that automatically. And it came up a few times already here too. See this question for example: Module uninstall dependencies ...
  • 81.7k
7 votes
Accepted

Does drush need to be installed as root?

Not sure exactly what's going on there but I can reproduce it using the installation instructions. The problem is related to the execution path (haven't looked any deeper). If you move out of the ...
  • 164k
7 votes
Accepted

Managing module library dependencies with composer

New method using drupal-scaffold for greatest flexibility For Drupal 8.4.0 and greater using drush >9.0.0, drush make is deprecated and you should use a full-composer work flow as detailed in the ...
  • 5,739
7 votes
Accepted

Programmatically build module permission list

You can list all available permissions with PermissionHandler: $permissions = \Drupal::service('user.permissions')->getPermissions(); You'll find the module name in the provider property of the ...
  • 90.3k
7 votes

Install Drupal using composer

Checking https://packagist.org/packages/drupal/drupal for the versions available there is NO 7.x version. Drupal 7 has no composer.json for this to command to work. You can use one of the other 2 ...
7 votes

Installation error with Composer

For Ubuntu 16.04 I had to run the following commands to adjust the PHP version used by Apache: sudo a2dismod php7.0 sudo a2enmod php7.2 sudo service apache2 restart
  • 425
7 votes

Grant permission for custom role from hook_install programmatically

Try this: use Drupal\user\Entity\Role; function mymodule_install() { $role_object = Role::load('my custom role name'); $role_object->grantPermission('my custom permission name'); $...
7 votes
Accepted

How do I programmatically install a module?

Use "module_installer" service. $installer = \Drupal::service('module_installer'); // Or from the container. $installer = $container->get('module_installer'); // Install single module. $installer-...
  • 865
6 votes

Drush CC all returning "No Drupal site found, only 'drush' cache was cleared"

Noting that your drush status output does give a valid root, site path, database user, and database name, that means that drush is finding a valid settings.php file with credentials in it and can read ...
  • 186
6 votes
Accepted

Drupal 8 Equivalent of Drupal 7's disabling a module without Uninstalling it

https://www.drupal.org/node/2225029 The long and the short of it is that you cant. This option is no longer available in Drupal and it was a conscious decision to remove the ability to disable a ...
  • 1,500
6 votes
Accepted

Disabling module with config sync and removing with composer

You need two consecutive releases for stuff like that. First release: Your colleague uninstalls the module and commits the updated config. If you don't manage your site via config use hook_update_N ...
  • 16.2k
6 votes

Disabling module with config sync and removing with composer

Adding an alternative solution to @leymannx - you will still need two releases. This is taking into consideration your mention of drush cim First release: Uninstall the module drush pmu module_name ...
  • 10.8k
6 votes

Cannot install Composer because it doesn't contain any .info.yml files

IMPORTANT EDIT (2020-04-28): You are trying to install this project: https://www.drupal.org/project/composer But that is not Composer -- it's a Drush extension for managing Composer. From the ...
  • 1,988

Only top scored, non community-wiki answers of a minimum length are eligible