Skip to content

Instantly share code, notes, and snippets.

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 21:35
Beispiel für RESTful Sensor in Home Assistant zur Abfrage des luftdaten.info API
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 %}
<?php
/**
* Class LuftdatenApi
*/
class LuftdatenApi
{
const BASE_URL = 'http://api.luftdaten.info/v1/sensor/';
/**
@mattsches
mattsches / Album.php
Created April 24, 2016 14:53
Example entity for DoctrineRestDriver issue
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* This annotation marks the class as managed entity:
*
* @ORM\Entity
@mattsches
mattsches / .filelist.txt
Created December 13, 2015 13:16
Liste von PHP-Dateien der Fotoverwaltung Lychee, die von Phan in dieser Reihenfolge eingelesen werden sollen.
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 / cors-test.html
Created September 20, 2015 14:40
Test page with description on how to test my pull request to the Calendar+ OwnCloud app.
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>OwnCloud Calendar+ CORS Test</title>
<script type="text/javascript">
var calendarICS = "###CALENDARICSURL###",
request = new XMLHttpRequest();
request.open('GET', calendarICS, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
@mattsches
mattsches / php_functions_frequencies.json
Created March 15, 2015 11:10
Frequency of internal PHP functions found on GitHub
[
{
"function":"zend_version",
"frequency":151465
},
{
"function":"func_num_args",
"frequency":779391
},
{
@mattsches
mattsches / keybase.md
Created October 5, 2014 08:31
keybase.md

Keybase proof

I hereby claim:

  • I am mattsches on github.
  • I am mattsches (https://keybase.io/mattsches) on keybase.
  • I have a public key whose fingerprint is F4D4 C888 055A 44C3 A5C3 33AB A8E6 AF25 C59F 4A27

To claim this, I am signing this object:

@mattsches
mattsches / fritzbox.ini
Created November 1, 2013 16:06
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
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 December 20, 2015 21:48 — forked from onli/layered.inc.php
Added charset to connection adapter
<?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