Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Coding

Jibran Ijaz jibran

👨‍💻
Coding
View GitHub Profile
@jibran
jibran / 20-xdebug.ini
Created Nov 19, 2020
To get xdebug to work.
View 20-xdebug.ini
zend_extension=xdebug.so
xdebug.max_nesting_level=256 ; Fixes debugging for D8.
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_connect_back=1
View gist:ef3d1a6cfae70b60010bb4a7ec78534f
$ mysql -uroot -proot -h127.0.0.1 -Dlocal
MariaDB [local]> SELECT * FROM mysql.general_log;
MariaDB [local]> SET global general_log = 1;
MariaDB [local]> SET global log_output = 'table';
// Run Queries.
MariaDB [local]> SELECT * FROM mysql.general_log;
MariaDB [local]> TRUNCATE mysql.general_log;
@jibran
jibran / DrupalDependenciesTest.php
Created Feb 13, 2019
Tests Drupal dependencies are correct.
View DrupalDependenciesTest.php
/**
* Tests Drupal dependencies are correct.
*/
public function testDrupalDependencies() {
$excluded_packages = [
'wikimedia/composer-merge-plugin',
'ircmaxell/password-compat',
];
$project_lock = json_decode(file_get_contents($this->root . '/composer.lock'), TRUE);
// Drupal 8.6.9 lock file.
@jibran
jibran / core-deps.sh
Last active Jan 2, 2020
Steps to update Drupal core dependencies
View core-deps.sh
git clone --branch 8.6.x https://git.drupal.org/project/drupal.git
cd drupal
composer config platform.php 5.5.9
composer install
composer outdated -D
// Choose the packages to update. Let's say we want to update symfony packages.
composer update symfony/*
composer config --unset platform
composer update --lock
git add composer.lock
View bootstrap.php
<?php
/**
* @file
* Boostrap for PHPUnit.
*/
use Drupal\Component\Assertion\Handle;
assert_options(ASSERT_ACTIVE, FALSE);
$autoloader = __DIR__ . '/../vendor/autoload.php';
$loader = require $autoloader;
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
@jibran
jibran / phpbrew.sh
Last active Mar 10, 2019
Install new PHP for Drupal
View phpbrew.sh
phpbrew install 7.3.3 +gd +zlib +zip +xml +wddx +tokenizer +sockets +session +readline +posix +pdo +pcre +pcntl +openssl +mbstring +mysql +json +iconv +hash +gettext +ftp +filter +fileinfo +exif +dom +curl +ctype +calendar +bz2
phpbrew switch php-7.3.3
phpbrew ext install xdebug
phpbrew ext install apcu
@jibran
jibran / FileEntity.php
Created Mar 24, 2017
Migrating Drupal 7 File Entities to Drupal 8 Media Entities
View FileEntity.php
<?php
// modules/custom/my_custom_module/src/Plugin/migrate/source/FileEntity.php
namespace Drupal\my_custom_module\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
/**
* Drupal 7 file_entity source from database.
@jibran
jibran / test.php
Created Feb 21, 2017
Drupal minimal bootstrap.
View test.php
<?php
/**
* @file
* Drupal minimal bootstrap.
*/
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
@jibran
jibran / gist:7afa1a6d90387e5ff674b6705b71af9b
Last active Jan 29, 2019
Basefield scenarios in Drupal 8
View gist:7afa1a6d90387e5ff674b6705b71af9b

There are 18 kind of different scenarios for basefield:

  1. non-translatable and non-revisionable entity with basefield with cardnality 1. One DB table: base Field column(s) in base table
  2. non-translatable and non-revisionable entity with basefield with cardnality greater than 1. Two DB tables: base, field table Field column(s) in field table
  3. translatable and non-revisionable entity with basefield with cardnality 1. Two DB tables: base, data Field column(s) in data table
    • non-translatable basefield.
    • translatable basefield.
  4. translatable and non-revisionable entity with basefield with cardnality greater than 1. Three DB tables: base, data, field table Field column(s) in field table
    • non-translatable basefield.
    • translatable basefield.
@jibran
jibran / field.field.node.article.field_der.yml
Created May 24, 2016
Difference between DER and ER fields.
View field.field.node.article.field_der.yml
uuid: 6ad5c377-24dc-4c3c-9ccf-027a87ced18f
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_der
- node.type.article
module:
- dynamic_entity_reference
id: node.article.field_der
You can’t perform that action at this time.