Skip to content

Instantly share code, notes, and snippets.

View enygma's full-sized avatar

Chris Cornutt enygma

View GitHub Profile
Executing step: Check out the repository
When directory "my-repo" does not exist
And I git clone "git.internal:/opt/git/my-repo"
>> Cloning into 'my-repo'...
Then change to directory "my-repo"
Then execute "pwd"
>> /Users/chris/work/picklebuild/my-repo
Then git checkout "release"
>> Switched to a new branch 'release'
>> Branch release set up to track remote branch release from origin.
@enygma
enygma / slim3-routes-invoke.php
Created December 13, 2015 17:16
Output Slim 3 routes to Invoke config (and grouping)
<?php
$routes = $app->getContainer()->get('router')->getRoutes();
$grouped = [];
foreach ($routes as $index => $route) {
$pattern = $route->getPattern();
preg_match('/\{.+?Id\}/', $pattern, $match);
if (isset($match[0])) {
@enygma
enygma / authn.php
Created November 3, 2015 13:07
An authentication example for PHP
<?php
interface Subject
{
public function getIdentifier();
public function getCredential();
}
interface Enforcer
{
@enygma
enygma / propauth-blade-provider.php
Created October 20, 2015 19:42
Laravel provider to introduce "@allows" and "@Denies" into Blade templates
<?php
namespace App\Providers;
use Blade;
use Illuminate\Support\ServiceProvider;
class PropAuthBladeServiceProvider extends ServiceProvider
{
/**
@enygma
enygma / gist:3906604
Created October 17, 2012 16:37
Change in Guzzle options for CURL and self-signed certs
<?php
/**
* When using Guzzle with self-signed certs, something recently changed that makes the
* previous manual config no longer work...see below
*/
// this no longer works
$init = array(
'curl.CURLOPT_SSL_VERIFYHOST' => false,
'curl.CURLOPT_SSL_VERIFYPEER' => false,
@enygma
enygma / gist:3494587
Created August 28, 2012 03:09
checking entities in XMLReader
<?php
$r = new XMLReader();
$r->xml($post);
while ($r->read()) {
if ($r->nodeType == 10) {
$doc = $r->readOuterXML();
// see if we have any entities
preg_match_all('#<!ENTITY (.*?)>#ims',$doc,$matches);
if (!empty($matches[1])) {
@enygma
enygma / property-auth-example.php
Created October 5, 2015 02:59
Example of the Property Auth engine working in a laravel app
<?php
// First, our service provider defining the policies
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Psecio\PropAuth\Enforcer;
use Psecio\PropAuth\Policy;
[Behat\Behat\Exception\ErrorException]
Exception has been thrown in "beforeSuite" hook, defined in FeatureContext::initMinkSessions()
<?php
// autoload_namespace.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
return array(
'Zend\\Validator' => $vendorDir . '/zendframework/zend-validator/php/',
'Zend\\Uri' => $vendorDir . '/zendframework/zend-uri/php/',
{
"require": {
"behat/behat": ">=2.2.2",
"behat/mink" : ">=1.3.2",
"guzzle/guzzle": ">=2.0.1",
"fabpot/goutte": "*",
"behat/sahi-client": "*",
"alexandresalome/php-selenium": "*",
"facebook/php-webdriver": "*"
},