Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shashankmehta
shashankmehta / setup.md
Last active January 7, 2024 11:57
Setup PHP and Composer on OSX via Brew

First install Brew on your MAC

  • Setup Brew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • brew update
  • brew tap homebrew/dupes
  • brew tap homebrew/php
  • Install PHP 7.0.+ brew install php70
  • Install mcrypt: brew install mcrypt php70-mcrypt
  • Finally, install composer: brew install composer
@morsok
morsok / referer.php
Last active February 28, 2022 10:22
Drupal 8 : Do something based on the referer if it's your website or another.
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request;
function my_function() {
$previousUrl = \Drupal::request()->server->get('HTTP_REFERER');
$fake_request = Request::create($previousUrl);
$url_object = \Drupal::service('path.validator')->getUrlIfValid($fake_request->getRequestUri());
if ($url_object) {
$route_name = $url_object->getRouteName();
// Do something with $route_name;