Skip to content

Instantly share code, notes, and snippets.

View jibran's full-sized avatar
👨‍💻
Coding

Jibran Ijaz jibran

👨‍💻
Coding
View GitHub Profile
@jibran
jibran / gist:53422800591460a5a4300aa65f98d520
Last active September 17, 2022 14:51
All the new stuff in Drupal 10.1.x
git log --oneline --reverse --no-merges --cherry-pick --right-only origin/10.0.x...origin/10.1.x
@jibran
jibran / path_to_request.php
Last active April 13, 2021 03:15
Setup current request to the given path in Drupal 8/9
<?php
// Setup page URL with all request parameters as current request and path.
$path = '/some-uri';
$request = Request::create($path);
$result = \Drupal::service('router.no_access_checks')->matchRequest($request);
$request->attributes->add($result);
\Drupal::requestStack()->push($request);
\Drupal::service('path.current')->setPath($path);
@jibran
jibran / 20-xdebug.ini
Created November 19, 2020 00:55
To get xdebug to work.
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
@jibran
jibran / gist:ef3d1a6cfae70b60010bb4a7ec78534f
Created December 1, 2019 12:20
Enable MySQL query logging.
$ 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]&gt; TRUNCATE mysql.general_log;
@jibran
jibran / DrupalDependenciesTest.php
Created February 13, 2019 14:16
Tests Drupal dependencies are correct.
/**
* 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 January 2, 2020 09:30
Steps to update Drupal core dependencies
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
<?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 March 10, 2019 13:06
Install new PHP for Drupal
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 March 24, 2017 00:39
Migrating Drupal 7 File Entities to Drupal 8 Media Entities
<?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 February 21, 2017 04:00
Drupal minimal bootstrap.
<?php
/**
* @file
* Drupal minimal bootstrap.
*/
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;