How to execute Phpstorm from the command line

Solution for Apple M1  - using homebrew:

> Settings -> Git -> Use System Git -> "/opt/homebrew/bin/git" (NOT "/usr/*/git")

This magically added "/opt/homebrew/bin" to SourceTree's $PATH and all git hooks started working again.

For macOS:

To get additional debug logging for troubleshooting launcher issues, set the environment variable before starting the IDE:

export IDEA_LAUNCHER_DEBUG=true

 

cd /Applications
./PhpStorm.app/Contents/MacOS/phpstorm

Bootstrap popover to dismiss on next click

The main idea is to use <a> element with  tabindex="0" attribute and data-bs-trigger should be focus instead of click:

<a tabindex="0" class="btn btn-lg btn-danger" 
role="button" data-bs-toggle="popover" 
data-bs-trigger="focus" title="Dismissible popover" 
data-bs-content="And here's some amazing content. It's very engaging. Right?">
Dismissible popover
</a>

Extend Ajax beforeSend method

Here we extend system Drupal.Ajax.prototype.beforeSend() method. We set progress variable according to data attribute. 

let ajaxBeforeSendOriginal = Drupal.Ajax.prototype.beforeSend;  
// Extend Drupal.Ajax.prototype.beforeSend.  
Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) {  
  // Set progress variable according to data attribute.  
  this.progress.type = $(this.element).data("ajax-progress") || 
  this.progress.type;  ajaxBeforeSendOriginal.call(this, xmlhttprequest, options);  
}; 

Useful Unix commands

Create archive:

tar -czvf theme.tgz theme_directory

v - to show process

To unarchive:

tar -xvf theme.tgz

To copy file to the server with SCP:

scp theme.tgz ubuntu@10.10.0.1:/var/www/drupal/web/themes/

Add the user ubuntu to the www-data group:

Views usefull snippets

To remove views unsaved changes, sometimes can be usefull when after views change you cannot access edit page.

drush eval "\Drupal::keyValueExpirable('tempstore.shared.views')->delete('VIEW_NAME');"


To get query from the view:

$query = $view->getQuery();
$query_string = $query->query()->__toString();
dpm($query_string);

To get arguments: 

Change schema version of a module

For Drupal8+:
Manually setting the current schema version of a module

drush eval "\Drupal::service('update.update_hook_registry')->setInstalledVersion('my_module', 9001);"

Or in this way:

\Drupal::keyValue('system.schema')->set('my_module', (int) 9001);

For Drupal 7:

drush ev "drupal_set_installed_schema_version('my_module', 7025)"


To get installed version for Drupal8+:

Disable cron

Drupal 7:

// Disable drupal's built in cron trigger.
$conf['cron_safe_threshold'] = 0;

Drupal 8/9:

// Disable drupal's built in cron trigger.
$config['automated_cron.settings']['interval'] = 0;