Skip to content

Instantly share code, notes, and snippets.

Jon LeMaitre GRAgmLauncher

Block or report user

Report or block GRAgmLauncher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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.