1. Go to this page and download the library: Download voral/version-increment 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/ */
voral / version-increment example snippets
use Vasoft\VersionIncrement\Events\EventType;
use Vasoft\VersionIncrement\Config;
use Vasoft\VersionIncrement\Contract\EventListenerInterface;
use Vasoft\VersionIncrement\SemanticVersionUpdater;
class Listener implements EventListenerInterface {
public function handle(\Vasoft\VersionIncrement\Events\Event $event): void
{
print_r([
$event->getData(SemanticVersionUpdater::LAST_VERSION_TAG) ?? 'unknown',
$event->eventType->name,
]);
}
}
$listener = new Listener();
$config = new Config();
$eventBus = $config->getEventBus();
$eventBus->addListener(EventType::BEFORE_VERSION_SET, $listener);
$eventBus->addListener(EventType::AFTER_VERSION_SET, $listener);
$eventBus->addListener(EventType::ON_ERROR, $listener);
use Vasoft\VersionIncrement\Exceptions\UserException;
throw new UserException(
code: 100, // Your custom error code (will be converted to 5100)
message: 'Custom error message describing the issue.'
);