Skip to content

Instantly share code, notes, and snippets.

View ananth-iyer's full-sized avatar

Ananth Iyer ananth-iyer

View GitHub Profile
@ananth-iyer
ananth-iyer / keybindings.json
Last active June 12, 2024 05:44
VS Code Keyword bindings for Terminal
/* Place your key bindings in this file to override the defaultsauto[] */
[
{
"key": "ctrl+tab",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"when": "terminalFocus",
"key": "ctrl+l",
@ananth-iyer
ananth-iyer / disable-xdebug.sh
Created October 12, 2023 05:05
Bash scripts to enable & disable xdebug in FPM/CLI for local development. Inspired by https://medium.com/@kayintveen/easily-enable-and-disable-xdebug-275f7edc5bad
#!/usr/bin/env bash
if ! test -f /etc/php/8.1/fpm/conf.d/20-xdebug.ini && ! test -f /etc/php/8.1/cli/conf.d/20-xdebug.ini; then
echo "
#
# Xdebug is not enabled
#
";
/usr/bin/php8.1 -v
exit
@ananth-iyer
ananth-iyer / php-fpm-mailcatcher.ini
Last active March 23, 2023 10:15
Integrate Mailcatcher with PHP FPM for Magento 2 email testing
; Run mailcatcher
; In Magento 2, Check Disable Email Communications is No
; https://php.net/smtp-port
smtp_port = 1025
sendmail_path = /usr/bin/env /usr/local/bin/catchmail --smtp-ip 127.0.0.1 -f sales@example.com
@ananth-iyer
ananth-iyer / emulate-event-observer.php
Created November 10, 2022 07:30
Emulate event observer for testing
<?php
use Magento\Framework\App\Bootstrap;
use Magento\Framework\DataObject;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
// set frontend scope - necessary
@ananth-iyer
ananth-iyer / Magento2-nginx-config-info.md
Last active November 29, 2020 13:46
Setup Nginx to work with Magento 2

Below is the M2 virtual hosts config file in /etc/nginx/sites-available/m2.m235p1.local.conf

server {
  listen 80;
  server_name m2.m235p1.local;

  set $MAGE_ROOT /var/www/html/m2235-p1;
  # set $MAGE_MODE production;

 include /var/www/html/m2235-p1/nginx.conf.sample;
@ananth-iyer
ananth-iyer / bashrc.md
Last active July 17, 2019 12:09
Show current branch name on Linux Ubuntu terminal without git branch command

**Open up your terminal/SSH and edit below file:

** nano ~/.bashrc

Use sudo command to edit file if you logged in with non-sudo user

Save the below lines at the end of .bashrc file

parse_git_branch() {
@ananth-iyer
ananth-iyer / m2_external_script.php
Last active September 24, 2020 11:00
Magento 2 External script
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
// set frontend scope - necessary
/** @var \Magento\Framework\App\State $state */
@ananth-iyer
ananth-iyer / CsrfValidatorSkip.php
Last active October 30, 2023 10:33
Magento 2.3.0: Implement below code to skip the CSRF check on your custom route called outside Magento environment. This implementation does not break core frontend/adminhtml routes, Magento 2.3/2.2/2.1 web stores.
<?php
namespace Vendor\Module\Plugin;
class CsrfValidatorSkip
{
/**
* @param \Magento\Framework\App\Request\CsrfValidator $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\App\ActionInterface $action
@ananth-iyer
ananth-iyer / check-m2-edition.php
Created February 27, 2019 08:01
Know the Magento edition in codebase like Community or Enterprise
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
@ananth-iyer
ananth-iyer / launch.json
Created February 9, 2019 11:09
Visual Studio Code Debug Configuration for Vue Storefront PWA
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",