Skip to content

Instantly share code, notes, and snippets.

@ivastly
Last active December 10, 2019 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivastly/955a45aadaa31a9f6241cd0577420220 to your computer and use it in GitHub Desktop.
Save ivastly/955a45aadaa31a9f6241cd0577420220 to your computer and use it in GitHub Desktop.
Typical PHP application
<?php
public function createNewUser($newUsername)
{
$start = time();
if (!$this->isGranted('ROLE_ADMIN'))
{
throw new AccessDeniedException();
}
$this->logger->info("Creating new user {$newUsername}");
$user = new User();
$user->setName($newUsername);
$this->entityManager->persist($user);
$this->entityManager->flush();
$this->logger->info("User {$newUsername} was created");
$totalTime = time() - $start;
header("X-Create-User-Total-Time: $totalTime sec");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment