Skip to content

Instantly share code, notes, and snippets.

@odan
odan / php-pdo-mysql-crud.md
Last active December 8, 2020 23:24
Basic CRUD operations with PDO and MySQL
@odan
odan / php-oracle.md
Last active November 13, 2020 20:03
XAMPP - Oracle Driver Setup (v12)
@odan
odan / rest_quick_reference.md
Last active September 1, 2021 20:06
REST, RESTful API Quick Reference
@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 / xmapp-replacing-mariadb-with-mysql.md
Last active February 19, 2022 17:29
XAMPP - Replacing MariaDB with MySQL
View xmapp-replacing-mariadb-with-mysql.md

XAMPP - Replacing MariaDB with MySQL

This post has been deleted.

@odan
odan / aspnet-core-2-ubuntu-setup.md
Last active March 25, 2023 11:26
Installing ASP.NET Core 2.1 on Ubuntu 18.4 Linux
View ExcelFileReader.php
<?php
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
/**
* ExcelFileReader.
*/
class ExcelFileReader
{
@odan
odan / mocking-interface-phpunit.md
Last active March 29, 2023 12:32
Mocking Interfaces with PHPUnit
View mocking-interface-phpunit.md

Mocking Interfaces with PHPUnit

Using the MockBuilder

To mock an interface with PHPUnit we have to pass all methods of the given Interface.

 $reflection = new \ReflectionClass(UserRepositoryInterface::class);

$methods = [];
@odan
odan / remove-namespaces-xml.php
Last active March 25, 2023 11:26
Remove all namespaces from XML in PHP (dirty hack)
View remove-namespaces-xml.php
<?php
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML(file_get_contents(__DIR__ . '/demo.xml'));
$dom = removeAllNamespaces($dom);
$dom->save('demo-out.xml');