Skip to content

Instantly share code, notes, and snippets.

View MahmoudSayed96's full-sized avatar
🏠
Working from home

Mahmoud Sayed Hassan MahmoudSayed96

🏠
Working from home
View GitHub Profile

Need to do this in both php.ini files !!!

Attention Wamp/Wordpress/windows users. I had this issue for hours and not even the correct answer was doing it for me, because i was editing the wrong php.ini file because the question was answered to XAMPP and not for WAMP users, even though the question was for WAMP.

here's what i did

Download the certificate bundle.

Put it inside of C:\wamp64\bin\php\your php version\extras\ssl

@MahmoudSayed96
MahmoudSayed96 / Blocks.md
Created November 14, 2022 09:05 — forked from davidjguru/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@MahmoudSayed96
MahmoudSayed96 / CustomLoginResource.php
Last active July 18, 2022 22:31
Drupal 8 rest custom login resource, return session data to build cookie in frontend, missing csrf (can be obtained at /rest/session/token). !!! This is a POST resource, so '$ drush cr', enable resource, and add a permission for anonymous role.
<?php
namespace Drupal\custom_rest_api\Plugin\rest\resource;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\rest\ModifiedResourceResponse;
use Drupal\rest\Plugin\ResourceBase;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Session\SessionManagerInterface;
@MahmoudSayed96
MahmoudSayed96 / .htaccess
Created July 12, 2022 13:42
apache2 redirect to https with www (https:/www.)
# source: https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/
# To redirect all users to access the site WITH the 'https://www.
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
@MahmoudSayed96
MahmoudSayed96 / mymodule.install
Created December 22, 2021 12:24 — forked from marcvangend/mymodule.install
Drupal 8: Custom path aliases exported to code.
<?php
/**
* @file
* Install, update and uninstall functions for my module.
*/
use Drupal\Core\Database\Database;
use Drupal\Core\Language\LanguageInterface;
/**