1. Go to this page and download the library: Download delboy1978uk/user library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
delboy1978uk / user example snippets
use Del\Person\Service\PersonService;
use Del\Service\UserService;
use Doctrine\ORM\EntityManager;
// $entityManager = [get your Doctrine EntityManager here];
$personService = new PersonService($entityManager);
$userService = new UserService($entityManager, $personService);
$user = $svc->createFromArray($data); // Pass an array, get a User object
$array = $svc->toArray($user); // Pass an User object, get an array
$user = $svc->saveUser($user); // Inserts or updates a User in the DB
$user = $svc->findUserById($id); // Finds a User in the DB
$user = $svc->findUserByEmail($email); // Finds a User in the DB
$user = $svc->changePassword($user, $password); // Updates a password in the DB
$users = $svc->findByCriteria($criteria); // See below for more info
$user = $svc->findOneByCriteria($criteria); // See below for more info
$svc->deleteUser($user); // Deletes a User from the DB
$svc->setUserClass($className); // If you wish to extend this class with your own
$svc->checkPassword($user, $plainPassword); // Returns true or false
$svc->registerUser($data); // See below
$svc->authenticate($email, $password); // Returns the user's ID on success
$emailLink = $svc->generateEmailLink($user, $daysTillExpiry); // For emailing with a secure token
$emailLink = $svc->findEmailLink($email, $token); // Finds the email link for that user
$emailLink = $svc->deleteEmailLink($link); // Deletes from the DB
$user = $svc->registerUser($data);
$emailLink = $svc->generateEmailLink($user, 7); // Token expires in 7 days
$emailLink = $svc->findEmailLink($email, $token);
use Del\Entity\User;
use Del\Person\Entity\Person;
use Del\Value\User\State;
$user = new User();
$user->setId(12345); // You shouldn't have to, the ORM will do this
$user->setEmail('[email protected]');
$user->setPassword($password); // Not encrypted - use the service which will in turn call this
$user->setState(new State(State::STATE_ACTIVATED));
$user->setRegistrationDate($registrationDate); // A DateTime object
$user->setLastLogin($registrationDate); // A DateTime object
$user->setPerson(new Person()); // See delboy1978uk/person
while ($collection->valid()) {
$user = $collection->current();
// Do things to user
$collection->next();
}
use Del\Criteria\UserCriteria;
use Del\Value\User\State;
$criteria = new UserCriteria();
$criteria->setState(State::STATE_UNACTIVATED); // We only want unactivated users
$users = $svc->findByCriteria($criteria);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.