PHP code example of maximaster / bitrix-agent

1. Go to this page and download the library: Download maximaster/bitrix-agent 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/ */

    

maximaster / bitrix-agent example snippets


composer 

use Maximaster\BitrixAgent\Agent\Agent;
use Maximaster\BitrixAgent\AgentRepository\AgentTable;
use Maximaster\BitrixAgent\AgentRepository\BitrixAgentRepository;
use Maximaster\BitrixValueObjects\Main\ModuleId;

$agent = Agent::flexible(
    'hello_world();',
    ModuleId::main(),
    new DateTimeImmutable(),
    new DateInterval('P1D')
);

$agentRepo = new BitrixAgentRepository();
$agentRepo->save($agent);

$agent = $agentRepo->allFit([AgentTable::NAME => 'hello_world();'])->get(0);

$agent->scheduleAt(new DateTimeImmutable('+1 day'));
$agentRepo->save($agent);

$agentRepo->remove($agent);

use Maximaster\BitrixAgent\Agent\Agent;
use Maximaster\BitrixAgent\AgentRepository\BitrixAgentRepository;

$agent = Agent::flexible(
    'hello_world();',
    ModuleId::main(),
    new DateTimeImmutable(),
    new DateInterval('P1D')
);
$agent->tag('service');

$agentRepo = new BitrixAgentRepository();
$agentRepo->save($agent);

$agents = $agentRepo->allTagged('service');