PHP code example of hollodotme / crontab-validator
1. Go to this page and download the library: Download hollodotme/crontab-validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hollodotme / crontab-validator example snippets
declare(strict_types=1);
namespaceMyVendor\MyProject;
usehollodotme\CrontabValidator\CrontabValidator;
$validator = new CrontabValidator();
if ( $validator->isExpressionValid( '6,21,36,51 7-23/1 * FEB-NOV/2 *' ) )
{
echo'Expression is valid.';
}
else
{
echo'Expression is invalid.';
}
declare(strict_types=1);
namespaceMyVendor\MyProject;
usehollodotme\CrontabValidator\CrontabValidator;
usehollodotme\CrontabValidator\Exceptions\InvalidExpressionException;
$validator = new CrontabValidator();
try
{
# => All fine, execution continues
$validator->guardExpressionIsValid( '6,21,36,51 7-23/1 * FEB-NOV/2 *' );
# => This will raise an InvalidExpressionException
$validator->guardExpressionIsValid( 'this is not a valid interval' );
}
catch ( InvalidExpressionException $e )
{
echo $e->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.