Skip to content

Instantly share code, notes, and snippets.

@odan
odan / factory.php
Last active August 14, 2017 14:26
Dependency Injection with PHP
View factory.php
<?php
class Configuration
{
private $settings = [];
public function __construct(array $settings)
{
$this->settings = $settings;
}
@odan
odan / slim4-cors-with-preflight-request.md
Last active May 18, 2020 21:01
Slim 4 - CORS with preflight request
View slim4-cors-with-preflight-request.md
@odan
odan / mock-flysystem-with-vfsStream.md
Last active July 2, 2020 12:02
Creating a mocked local filesystem adapter with vfsStream
View mock-flysystem-with-vfsStream.md

Creating a mocked local Flysystem adapter with vfsStream

Note: In this example I doesn't use the flysystem Memory or Null adpater, because the Memory adapter doesn't implement the getPathPrefix method, like the AbstractAdapter does. For this reason I use the Local adapter in LOCK_NB mode in combination with vfsStream to simulate the filesystem in-memory.

Setup

composer require mikey179/vfsstream --dev
@odan
odan / php-oracle.md
Last active November 13, 2020 20:03
XAMPP - Oracle Driver Setup (v12)
@odan
odan / php-pdo-mysql-crud.md
Last active December 8, 2020 23:24
Basic CRUD operations with PDO and MySQL
@odan
odan / soap-xmldsig.md
Created June 1, 2021 14:23
Sign SOAP messages with xmlseclibs
View soap-xmldsig.md

Sign SOAP messages with xmlseclibs

Requirements

  • PHP 7.4+
  • OpenSSL

Generating Public and Private Keys

First we have to create a private key for signature creation, and a public key for verification.

View User Authentication System.md

User authentication system

Your task is now to create a user authentication system.

This document will guide you through all the features and implication of such system, so that you don't have to search them yourself.

We will focus on web/browser-technologies, however similar concept can be widely applied. This guide, is a work in progress, feel free to comment and provide feedbacks.

Expected Workflows

@odan
odan / rest_quick_reference.md
Last active September 1, 2021 20:06
REST, RESTful API Quick Reference
@odan
odan / Slim 4 Tutorial.md
Last active January 15, 2022 11:22
Slim 4 Tutorial
View Slim 4 Tutorial.md
@odan
odan / mock-ramsey-uuid.md
Last active February 16, 2022 16:53
Mock Ramsey\Uuid
View mock-ramsey-uuid.md

Mock Ramsey\Uuid

The mock trait

<?php

namespace App\Test\Traits;

use Ramsey\Uuid\Generator\RandomGeneratorInterface;