Skip to content

Instantly share code, notes, and snippets.

@litzinger
litzinger / ddev.md
Created Dec 4, 2020
Use Xdebug 3 in PHP 7.3/4
View ddev.md

https://stackoverflow.com/questions/65137275/how-can-i-use-xdebug-3-0-with-php-7-3-or-7-4-in-ddev/65137276#65137276

DDEV-Local depends on the deb.sury.org Debian packages for PHP, so will follow those as the changes are made. Currently deb.sury.org packages PHP8.0 with xdebug 3.0, but it's not hard to get xdebug 3.0 with earlier PHP versions until that changes.

You can compile and install xdebug 3.0 for PHP7.3 or 7.4. Place this file as .ddev/web-build/Dockerfile in your project's .ddev directory:

ARG BASE_IMAGE
FROM $BASE_IMAGE
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests php-dev php-pear build-essential
@litzinger
litzinger / .phpstorm.meta.php
Last active Feb 18, 2020
PhpStorm meta file for ExpressionEngine
View .phpstorm.meta.php
<?php
/**
* ExpressionEngine PhpStorm Meta
*
* This file is not a CODE, it makes no sense and won't run or validate
* Its AST serves PhpStorm IDE as DATA source to make advanced type inference decisions.
*
* @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
*/
View Static rules
Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
@litzinger
litzinger / FieldAbstract.php
Created Aug 2, 2019
ExpressionEngine fieldtype abstract and interface for simplifying building fieldtypes
View FieldAbstract.php
<?php
abstract class FieldAbstract extends EE_Fieldtype
{
/**
* The settings from the db that EE passes to the ft file
* @var array
*/
public $settings = [];
@litzinger
litzinger / DateTime.php
Created Jun 5, 2019
Crude attempt at supporting Elasticsearch date math values in PHP's DateTime object
View DateTime.php
<?php
namespace MyNamespace;
/**
* @author Ton Sharp
* @author Brian Litzinger
* @see https://gist.github.com/66Ton99/60571ee49bf1906aaa1c
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.3/common-options.html#date-math
*/
@litzinger
litzinger / index.js
Last active Jan 4, 2021
Simple Puppeteer screenshot script
View index.js
/*
If saving AWS creds locally they need to be in ~/.aws/credentials
[default]
aws_access_key_id = foo
aws_secret_access_key = bar
*/
const puppeteer = require('puppeteer');
const AWS = require('aws-sdk');
@litzinger
litzinger / ee-tips.md
Last active Dec 19, 2019
ExpressionEngine Quick Tips
View ee-tips.md

Forcing a database update

If you're in a situation where you've already updated EE, but then need to run the database upgrades again, this will help force the installer to run the updates again. This situation may occur if you've upgrade a local or dev version of a site, but need to grab a newer version of the production database to get it up-to-date too.

  1. Change $config['app_version'] to the previous version you've already upgraded from.

  2. Add define('INSTALL_MODE', TRUE); to your admin.php file, then reload admin.php. Clicking the version number in the footer should show an update is available, even though it may match what says is currently installed. Run the update normally, then remove define('INSTALL_MODE', TRUE); from your admin.php file.

@litzinger
litzinger / grid.css
Created Sep 19, 2018
Simple CSS Grid layout without a framework
View grid.css
.container {
padding: 0 1rem;
margin: 0 auto;
}
@media screen and (min-width: 992px) {
.container {
max-width: 1140px;
}
.grid-wrapper {
display: grid;
View gist:7719412e728bb0f7579b6dcaad1d3d91
{
// 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
// Set the IDEKEY in the browser Xdebug Helper extension to "vscode"
"version": "0.2.0",
"configurations": [
{
@litzinger
litzinger / hook.php
Created Oct 31, 2017
Publisher hook example
View hook.php
<?php
$query = $this->query->modify(
'ORDER BY',
' AND ae.publisher_lang_id = '. $publisher_lang_id .' AND ae.publisher_status = "'. $publisher_status .'" ORDER BY',
$sql
);
// Publisher is disabled, but we still need to get default rows,
// otherwise it'll show duplicate rows.