jpi/cron-linter

Tool for linting cron files and expressions

Maintainers

Package info

github.com/jahidulpabelislam/cron-linter

pkg:composer/jpi/cron-linter

Transparency log

Statistics

Installs: 53

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v2.0.0 2026-07-16 20:10 UTC

README

CodeFactor Latest Stable Version Total Downloads Latest Unstable Version License GitHub last commit (branch)

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.

Installation

composer require --dev jpi/cron-linter

Add a .cronlinter.yml file to your project root that specifies a list of cron files to lint.

files:
  - /cron-1
  - /cron-2

File paths can also include glob patterns to match multiple files at once.

files:
  - /etc/cron.d/*
  - /cron.*

Then 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
$linter = \JPI\CronLinter::lintFiles($files, $baseDir);

// Lint cron content directly
// $expression is a string containing one or more cron expressions (one per line)
$linter = \JPI\CronLinter::lintContent($expression);

// Both methods return a CronLinter instance
// Call getErrors() to retrieve errors, grouped by file path (or empty string for content linting)
// Returns an empty array if no errors found
$errors = $linter->getErrors();

// Call getNumberOfFilesChecked() to retrieve the number of files that were checked
$numberOfFilesChecked = $linter->getNumberOfFilesChecked();

Support

If 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 😏.

Authors

Licence

This module is licenced under the GNU General Public Licence - see the licence file for details