Download the PHP package makinacorpus/cron without Composer

On this page you can find all versions of the php package makinacorpus/cron. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cron

Applicative cron task runner

Simple applicative cron task implementation.

How it works:

Simply put, it takes a task list, test each task schedule against current date, and run it when it matches.

State is per default kept in memory during runtime, then discarded. Future implementations will allow you to store it within PDO and maybe other backends.

State when persisted allows the user to change task schedule without changing the code. Schedule is always stored as a raw string which allows alternative implementations to exist.

Default schedule implementation accepts incomplete POSIX cron expression but only with single digit values. An alternative implementation can use dragonmantank/cron-expression for a more complete POSIX cron expression.

Roadmap

How to use

First, install it:

Then proceed with one of the following.

Standalone

Configuring cron tasks

First, create some cron methods:

Then create a task registry:

Running it

Then, create a runner and execute it, this is basically the piece of code you need to have in your CLI script that executes the cron:

And that's it.

Per default, schedule is forgiving, you may run this script only every 2 or 3 minutes, cron rules will match in a 5 minutes time span after their due date to avoid missing running them.

Symfony

Installing

Start by adding the bundle to the config/bundles.php file:

Configuring cron tasks

Create some services that have cron task methods, it can litteraly be any class or service, the only requirement is to set the CronTask attribute over the targeted methods:

Using the makinacorpus/argument-resolver dependency, considering you installed and configured the provided bundle, your methods can have other services as parameters, they will be injected at runtimme.

Make sure they are services in config/services.yaml or via any other service registration method:

And that's it.

Usage

Configuring schedule implementation

Default implementation

Default implementation if configuration is left untouched supports incomplete POSIX cron expressions, where parts can only be single digits.

For a lot of applications, this is more than enough.

You don't need to configure anything since this is the default.

dragonmantank/cron-expression

First install it:

Then, during your application bootstrap, call:

And use this API as you would normally do.

Commands

Commands are available when using it as a Symfony bundle, but nothing prevents you from setting up and using those outside of the Symfony full stack framework usage.

Run all cron tasks (that should run every minute)

Set this in your system cron, or supervisord, or any other orchestrator application:

You can run it manually as well:

Force run a single cron task

Simply call the same command, adding the cron task identifier as first argument:

Task configuration

Set a minimum interval

Write me.

Running tests

Core tests

Simply run PHPUnit:

Database related tests will be skipped due to the lack of configuration.

Database related tests

This uses docker compose for spawning a database environement:

This is experimental, it should work.


All versions of cron with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
psr/log Version >= 1.0
makinacorpus/argument-resolver Version ^1.0.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package makinacorpus/cron contains the following files

Loading the files please wait ....