Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon LeMaitre GRAgmLauncher

View GitHub Profile
View FooContext.php
interface FooContext {
public function foo(); // i.e. cache
public function bar(); // i.e. dbConnection
public function baz(); // i.e. logger
}
// If we're not doing dependency injection, then you need to handle permutations like below...
// It's easy to see how quickly this gets out of control
@GRAgmLauncher
GRAgmLauncher / APIRequest.php
Last active Aug 29, 2015
API request validator concept
View APIRequest.php
<?php
class APIRequest extends FormRequest
{
public function response(array $errors)
{
if ($this->ajax() || $this->wantsJson())
{
return new JsonResponse($errors, $this->responseCode());
}
You can’t perform that action at this time.