Skip to content

Instantly share code, notes, and snippets.

@RWhar
RWhar / signedS3Links.php
Last active August 29, 2015 14:17
Signed S3 Links
@RWhar
RWhar / sesSwiftMail.php
Last active August 29, 2015 14:17
Send email with Swift & SES
<?php
/**
* Requires
* "swiftmailer/swiftmailer": "5.*"
* "aws/aws-sdk-php": "2.7.25"
*/
use Aws\Common\Credentials\Credentials;
use Aws\Ses\SesClient;
@RWhar
RWhar / nonConcurrentScript.php
Last active December 11, 2023 07:01
Prevent concurrent execution of PHP Script
/**
* Creates an exclusive lock
* @param $lockDir Directory to create/access lock file
* @param $lockName Name for lock
* @param $lockHandle Reference to scope var to maintain file handle after lock call completes
* @return bool
* @throws Exception on $lockdir not writable, unable to create file handle, unable to obtain ex_lock
*/
function lock($lockDir, $lockName, &$lockHandle)
{
@RWhar
RWhar / PHPUnitMockMagicGet
Last active July 26, 2022 06:16
PHPUnit - Mock _get() on an Abstract Class
class TestMyObjectLoader extends PHPUnit_Framework_TestCase
{
protected $mockObject;
public function setUp()
{
$this->mockObject = $this->getMockForAbstractClass('Project\MyObject', [], '', true, true, true, ['initialize', '__get']);
}