Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthias Gutjahr mattsches

View GitHub Profile
View laravel facades discussion.md

Found an example there is a thing in laravel called FormRequest. Sometimes, I need extra validation. So I need to use some service there somehow. What options I have

  1. facade
  2. service locator via app() global function
  3. I also have instance of container there via $this->container

which one is the best here? I suppose instance of container

I can't do constructor injection. Why? Because for me, it seams that there are too many arguments on the __construct method

@mattsches
mattsches / configuration.yaml
Created May 8, 2017
Beispiel für RESTful Sensor in Home Assistant zur Abfrage des luftdaten.info API
View configuration.yaml
sensor:
- platform: rest
resource: http://api.luftdaten.info/v1/sensor/1777
value_template: >
{% if value_json is sequence %}
{% set sensor = value_json | last %}
{% else %}
{% set sensor = value_json %}
{% endif %}
{% for sdv in sensor.sensordatavalues %}
@mattsches
mattsches / Roman.php
Created Jan 30, 2013
PHP Roman Numerals Code Kata solution. A collaborative effort of the people @ PHP User Group Rheinhessen, Jan '13.
View Roman.php
<?php
/**
* Converts Roman numbers to integers
*/
class Roman
{
/**
* @var array
*/
View luftdatenapi.php
<?php
/**
* Class LuftdatenApi
*/
class LuftdatenApi
{
const BASE_URL = 'http://api.luftdaten.info/v1/sensor/';
/**
@mattsches
mattsches / Album.php
Created Apr 24, 2016
Example entity for DoctrineRestDriver issue
View Album.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* This annotation marks the class as managed entity:
*
* @ORM\Entity
@mattsches
mattsches / fritzbox.ini
Created Nov 1, 2013
Sample Config, um mit der FRITZ!Box 7320 (Firmware-Version: 100.05.51) einen VPN-Tunnel aufzubauen. Mehr in meinem Blogpost unter http://blog.sperr-objekt.de/content/1000423-VPN-Tunnel-mit-der-FRITZ!Box-7320-und-Linux.html
View fritzbox.ini
vpncfg {
connections {
enabled = yes;
conn_type = conntype_user;
name = "MEINVPN";
always_renew = no;
reject_not_encrypted = no;
dont_filter_netbios = yes;
localip = 0.0.0.0;
local_virtualip = 0.0.0.0;
@mattsches
mattsches / layered.inc.php
Last active Dec 20, 2015 — forked from onli/layered.inc.php
Added charset to connection adapter
View layered.inc.php
<?php
use Zend\Db\Sql\Sql;
use Zend\Db\Sql\Select;
use Zend\Db\Adapter\Adapter;
$result = null;
/**
* Tells the DB Layer to start a DB transaction.
*
* @access public
@mattsches
mattsches / .filelist.txt
Created Dec 13, 2015
Liste von PHP-Dateien der Fotoverwaltung Lychee, die von Phan in dieser Reihenfolge eingelesen werden sollen.
View .filelist.txt
data/config.php
php/define.php
php/autoload.php
php/modules/Album.php
php/modules/Database.php
php/modules/Import.php
php/modules/Log.php
php/modules/Module.php
php/modules/Photo.php
php/modules/Plugins.php
@mattsches
mattsches / sf2tt_001.php
Created Jun 16, 2012
EventListener mit PRE_SET_DATA-Event in Symfony2
View sf2tt_001.php
/* ... */
public function buildForm(FormBuilder $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA,
function (DataEvent $event) use ($builder)
{
$form = $event->getForm();
/* @var \Sperrobjekt\Sf2ttBundle\Entity\Category $data */
$data = $event->getData();
@mattsches
mattsches / test.php
Created Feb 22, 2012 — forked from rodneyrehm/test.php
PHPGangsta: Doppelte Array-Einträge entfernen
View test.php
<?php
if (extension_loaded('xdebug')) {
echo "WARNING: xdebug is enabled\n";
}
function _count()
{
$array = array(1, 5, 8, 'Michael', 5, 4, 9, 'Martin', 18, 12, 'Michael', 4, 12);