PHP code example of voral / version-increment

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;

$config = new Config();

$eventBus = $config->getEventBus();
$eventBus->on(EventType::BEFORE_VERSION_SET, function ($event) {
    echo "Starting version update...\n";
});

$eventBus->on(EventType::AFTER_VERSION_SET_SUCCESS, function ($event) {
    echo "Version successfully updated to {$event->getNewVersion()}.\n";
});

$eventBus->on(EventType::AFTER_VERSION_SET_ERROR, function ($event) {
    echo "Error updating version: {$event->getError()->getMessage()}\n";
});

  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.'
  );
  
json
{
  "scripts": {
    "vinc:major": "php ./vendor/bin/vs-version-increment major",
    "vinc:minor": "php ./vendor/bin/vs-version-increment minor",
    "vinc:patch": "php ./vendor/bin/vs-version-increment patch",
    "vinc:auto": "php ./vendor/bin/vs-version-increment",
    "vinc:list": "php ./vendor/bin/vs-version-increment --list",
    "vinc:debug:auto": "php ./vendor/bin/vs-version-increment --debug"
  }
}
bash
./vendor/bin/vs-version-increment && echo 'Ok' || echo 'Error'