Giter Site home page Giter Site logo

shamsic's Introduction

Shamsic

Maybe it happened to you that you wanted to use CronJob in your project and you realized that you cannot manage the exact dates that are in the solar calendar.

For example, cron job allows you to run your script on specific days of the week, month! But CronJob supports the Gregorian calendar.It is useless or can be done with low accuracy for the solar date!

This package allows you to solve this problem inside the PHP code.

This package supports PHP 8.1+.


Install

Via Composer

$ composer require ghaninia/shamsic

How to use

You need to configure the cron job on the server ,The crontab command shown below will activate the cron tasks automatically every minutes:

* * * * * php output.php

'*' is a wildcard, meaning "every time". If you don't have any background about CronJob expressions and don't clear for you, follow the link crontab.

The last three expressions of the cronJob are for the day of the month, the month and the day of the week. (Our main problem)

Now, open the file that will be executed by Cron Job (for this example output.php).

use GhaniniaIR\Shamsic\Schedule;

### At every minute on saturday in farvardin.
(new Schedule)
    ->call(function(){
        echo "test";
    })
    ->cron("* * * 1 2");

### At every minute on every day-of-week from saturday through thursday in khordad.
(new Schedule)
    ->call(function(){
        echo "test";
    })
    ->cron("* * * 3 1-5");

### At every minute on day-of-month 5 in farvardin.
(new Schedule)
    ->call(function(){
        echo "test";
    })
    ->cron("* * * 3 1-5");
... 


### After writing all the schedules, you must run them
Schedule::run();

If you want to check that your expression is valid or not :

(new ExecuteExpression("* * * * *"))->isValid();

shamsic's People

Contributors

ghaninia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.