1. Go to this page and download the library: Download dmk/mkoptin 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/ */
dmk / mkoptin example snippets
class MyAwesomeManager
{
private OptinManager $optinManager;
public function __construct(
OptinManager $optinManager
) {
$this->optinManager = $optinManager;
}
protected function handleOptIn(string $email): void
{
$optin = $this->optinManager->createOptinForEmail($email);
// opt in already done :)
if ($optin->isValidated()) {
// opt-in already performed, do your finalize stuff here
return;
}
// opt-in outstanding, send opt-in mail
// finalize stuff has to be performed by event listener after opt-in validation
$this->optinManager->sendValidationMailForOptin($optin);
}
}
class OptinValidationSuccessEventListener
{
private MyAwesomeManager $manager;
public function __construct(
MyAwesomeManager $manager
) {
$this->manager = $manager;
}
public function __invoke(OptinValidationSuccessEvent $event): void
{
$this->manager->handleOptinValidation($event->getOptin());
}
}
class MyAwesomeManager
{
public function handleOptinValidation(Optin $optin): void
{
// opt-in performed, do your finalize stuff here
}
}