Skip to content

Instantly share code, notes, and snippets.

View mxr576's full-sized avatar

Dezső BICZÓ mxr576

View GitHub Profile
@mxr576
mxr576 / .eslintrc.yml
Created June 27, 2022 06:25
Experimenting with linting yaml-s with eslint-plugin-yml
extends:
- plugin:yml/standard
rules:
yml/block-mapping:
- error
- always
yml/block-sequence:
- error
- always
yml/quotes:
@mxr576
mxr576 / check_config_changes.sh
Last active June 15, 2022 14:44
Drupal: Check config changes caused by https://www.drupal.org/node/3230199
##############################################################################
# This is a KISS script to compare configuration changes caused by https://www.drupal.org/node/3230199
# Make sure https://github.com/homeport/dyff is installed before you use this.
# License GPL-2.0-or-later.
###############################################################################
#!/usr/bin/env bash
echo "Enter the path of the original config directory, e.g.: /foo/bar/build/config"
read -r old_config_dir
@mxr576
mxr576 / Annotation_MyModuleEntityType.php
Last active September 4, 2021 18:14
"Smart" (content) entity type base in Drupal 8/9/10?
<?php
declare(strict_types = 1);
namespace Drupal\my_module_entity\Annotation;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\my_module_entity\Entity\MyModuleEntityType as MyModuleEntityTypeClass;
@mxr576
mxr576 / onion-arch-symfony-app.md
Created May 23, 2021 13:31
Code organization example of an onion-based Symfony app
// source: https://blog.itsjavi.com/target-software-architectures-the-onion-architecture
/tests
/src
    /Application
        /UseCase
            /CreateOrder
                CreateOrderRequest
                CreateOrderResponse
                CreateOrderUseCase
@mxr576
mxr576 / ddd_cqrs_event-sourcing_in_php.md
Created January 31, 2021 11:15 — forked from jsor/ddd_cqrs_event-sourcing_in_php.md
DDD, CQRS and Event Sourcing in PHP

DDD, CQRS and Event Sourcing in PHP

  • Broadway - Infrastructure and testing helpers for creating CQRS and event sourced applications
  • EventCentric.Core - Event Sourcing and CQRS in PHP
  • LiteCQRS - Small convention based CQRS library for PHP
  • predaddy - Common DDD classes including an annotation driven message bus and tools for CQRS and Event Sourcing
  • ProophEventSourcing - Provides basic functionality for event-sourced aggregates
  • ProophEventStore - PHP 5.4+ EventStore Implementation
  • ProophServiceBus - PHP Enterprise Service Bus Implementation supporting CQRS and DDD
@mxr576
mxr576 / benchmark.php
Created May 9, 2019 07:49
is_a() vs. reflection benchmark
<?php
$cnt = 10000000;
interface FooInterface {}
class BarClass implements FooInterface {
}
$x = 0;
@mxr576
mxr576 / apigee_edge_cleanup.php
Last active July 6, 2018 11:10
The Ultimate Apigee Edge clean up script in PHP - WARNING: Use it on your own risk!!!
<?php
require_once "vendor/autoload.php";
use GuzzleHttp\Client;
use GuzzleHttp\Promise;
$endpoint = getenv('APIGEE_EDGE_ENDPOINT') ?: 'https://api.enterprise.apigee.com/v1';
$org = getenv('APIGEE_EDGE_ORGANIZATION');
$client = new Client(['base_uri' => "{$endpoint}/o/{$org}/", 'auth' => [getenv('APIGEE_EDGE_USER'), getenv('APIGEE_EDGE_PASSWORD')]]);
@mxr576
mxr576 / oauth.php
Last active July 2, 2018 13:49
Apigee PHP API client OAuth test
<?php
require_once "vendor/autoload.php";
require_once "examples/authentication.inc";
$envCredProd = new EnvironmentCredentialProvider();
$auth = new \Apigee\Edge\HttpClient\Plugin\Authentication\Oauth($envCredProd->getUsername(), $envCredProd->getPassword(), new \Apigee\Edge\Tests\Test\HttpClient\Plugin\InMemoryOauthTokenStorage(), null, getenv('APIGEE_EDGE_PHP_SDK_CLIENT_ID') ?: null, getenv('APIGEE_EDGE_PHP_SDK_CLIENT_SECRET' ?: null), null, getenv('APIGEE_EDGE_PHP_SDK_AUTH_SERVER') ?: null);
$client = new \Apigee\Edge\Client($auth);
$envc = new \Apigee\Edge\Api\Management\Controller\EnvironmentController($envCredProd->getOrganization(), $client);
try {
@mxr576
mxr576 / pass_by_reference_in_php.md
Last active September 8, 2017 19:19
Why you should not use pass by reference in PHP

First example

Run: https://3v4l.org/VV51q

<?php

$a = 1; $b = &$a; $b = 42; print $a;

This is pretty simple, isn't it?

@mxr576
mxr576 / my_module.module
Last active March 6, 2017 10:31
Drupal: Search API : Provide default Search API server which configuration can be overridden with variables
<?php
/**
* Implements hook_default_search_api_server().
*/
function MY_MODULE_default_search_api_server() {
$items = [];
$host = variable_get('solr_search_api_host', 'localhost');
$scheme = variable_get('solr_search_api_scheme', 'http');