Skip to content

Instantly share code, notes, and snippets.

View voku's full-sized avatar
:octocat:
There is nothing good unless you do it.

Lars Moelleken voku

:octocat:
There is nothing good unless you do it.
View GitHub Profile
@voku
voku / StringLib.php
Created May 2, 2018 07:07
simple, small and dependency-free version of https://github.com/voku/portable-utf8
<?php
/**
* Class StringLib
*
* @see https://github.com/voku/portable-utf8
*/
class StringLib {
/**
@voku
voku / validation_date.php
Created June 5, 2014 05:55
date format validation: Validate a date in "YYYY-MM-DD" format. - From http://snippetlib.com/php/date_format_validation
<?php
/**
* check for date-format
*
* @param string $date valid is only "YYYY-MM-DD"
*
* @return bool
*/
function checkDateFormat($date)
@voku
voku / code_check_git_hook.php
Created December 10, 2018 23:05
A pre-commit-hook example with Code Sniffer + Code Fixer + PHPStan
#!/usr/bin/php
<?php
/**
* //
* // add something like this in your "composer post-update-cmd && post-install-cmd"
* //
* echo "\n\n";
* echo "Run force \"code_check_git_hook.php\" as pre-commit-hook ...";
* $force_pre_commit_hook_cmd = 'ln -sf YOUR_PATH_TO_CODE_CHECK_SCRIPTS/code_check_git_hook.php YOUR_PATH_TO_PROJECT_ROOT/.git/hooks/pre-commit';
@voku
voku / input_filter.php
Last active September 27, 2020 06:30
use input filter for php (get, post, get_post, session, cookie)
<?php
//define('SECONDS_IN_A_MINUTE', 60);
//define('SECONDS_IN_A_HOUR', 3600);
//define('SECONDS_IN_A_DAY', 86400);
//define('SECONDS_IN_A_WEEK', 604800);
//define('SECONDS_IN_A_MONTH', 2592000);
//define('SECONDS_IN_A_YEAR', 31536000);
/**
@voku
voku / mod-ide-helper.php
Created February 4, 2020 22:08
generate "PHPSTORM_META" dynamic
#!/usr/bin/php
<?php
namespace my_helper {
// init
$str = '';
require_once __DIR__ . '/boostrap.php';
require_once __DIR__ . '/etc/config.php';
-ea
-server
-Xss2m
-Xms2G
-Xmx5G
-XX:MaxMetaspaceSize=2G
-XX:MetaspaceSize=512m
-XX:ReservedCodeCacheSize=1G
-XX:+DoEscapeAnalysis
-XX:SoftRefLRUPolicyMSPerMB=50
@voku
voku / checkEmail.php
Last active March 24, 2019 01:37
check for E-Mail
<?php
/**
* checkEmail
*
* @param String $email
* @param Boolean $mxCheck (do not use, if you don't need it)
*
* @return Boolean
*/
@voku
voku / .htaccess
Last active February 13, 2019 01:32
.htaccess - example
# [simple.cms] + Apache Server Configs v3.1.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html
# ----------------------------------------------------------------------
@voku
voku / Makefile
Created December 10, 2018 23:38
A Makefile example from a php project with support for different code quality tools.
# WARNINGS && INFO:
# - a "\t" (tab) is needed before the commands, do not use spaces ..."
# - a "$" has special meaning in Makefiles, you need to double it to pass it)
# - please install/use the "Makefile support"-plugin for PhpStrom :)
TEST_ENV ?= local
CHECK_FILES ?= .
PHPSTAN_LEVEL ?= 3
@voku
voku / check_code_phpstan.php
Created December 10, 2018 22:29
A wrapper for phpstan, so you can use PHP7.0 and PHP7.1
#!/usr/bin/php
<?php
use Composer\XdebugHandler\XdebugHandler;
require_once __DIR__ . '/YOUR_PATH_THE_AUTOLOADER.php';
$xdebug = new XdebugHandler('phpstan-code-check');
$xdebug->check();
unset($xdebug);