Lint cron files. Based on the work of @Dave13h from https://github.com/Dave13h/php-censor-cronlint-plugin, just the PHPCensor aspect removed and made into a standalone package.
composer require --dev jpi/cron-linterAdd a .cronlinter.yml file to your project root that specifies a list of cron files to lint.
files:
- /cron-1
- /cron-2Then run php vendor/bin/lintcron, which will list any errors found in the specified cron files. You can use a different config file location using the --config-file option.
You can also specify files to be linted using the --files option, providing a comma-separated list of file paths.
Or if you want to do it programmatically on files or content.
// Lint cron files
// $files is an array of file paths for cron files to check
// $baseDir (optional) is a string containing the base directory path for all file paths
$errors = \JPI\CronLinter::lintFiles($files, $baseDir);
// Lint cron content directly
// $expression is a string containing one or more cron expressions (one per line)
$errors = \JPI\CronLinter::lintContent($expression);
// Both methods return an array of error messages, or an empty array if no errors foundIf you found this library interesting or useful please spread the word about this library: share on your socials, star on GitHub, etc.
If you find any issues or have any feature requests, you can open a issue or email me @ jahidulpabelislam.com 😏.
This module is licenced under the GNU General Public Licence - see the licence file for details