CronExpressionGenerator
v1.10.2
Cron Expression Generator adalah alat yang indah untuk aplikasi PHP. Tentu saja, fitur utama dari paket ini adalah kemampuan untuk menghasilkan ekspresi cron.
Generator Ekspresi Cron
Ekspresi yang dibangun sebelumnya
Ekspresi Kustom
Didokumentasikan dengan baik
Diuji dengan baik
Kompatibel dengan Laravel
PHP 8.0 ke atas
Anda dapat menginstal paket melalui komposer:
Komposer membutuhkan Butschster/Cron-Expression-Generator
Itu saja!
Gunakan ButschstercronexpressionGenerator; gunakan croncronexpression; $ generator = generator baru (); // atau $ generator = generator baru (cronexpression baru (' * * * * *')); // atau $ generator = generator :: create ();/ / atau $ generator = generator :: create (cronexpression baru (' * * * * *'));
$ ekspresi = $ generator-> getExpression (); // Croncronexpression
echo $ generator-> toExpression (); // * * * * * echo (string) $ generator; // * * * * * echo (string) $ generator-> getExpression (); // * * * * * echo $ generator-> getExpression ()-> getExpression (); // * * * * *
echo $ generator-> cron (' * * */3 * * *'); // * */3 * * * echo $ generator-> cron (' * */3 * * *')-> everytwominutes (); // */2 */3 * * *
// setiap menit $ generator-> everyminute (); // * * * * * // setiap bahkan Minutesecho $ Generator-> everyevenminute (); // */2 * * * * // setiap dua menit. // */2 * * * * // Setiap tiga menit. // */3 * * * * // Setiap empat menit. // */4 * * * * // setiap lima menit. // */5 * * * * // setiap sepuluh menit. // */10 * * * * // setiap lima belas menit $ generator-> everyfifteenminutes (); // */15 * * * * // Setiap 00 dan 30 menit $ generator-> everytyminutes (); // 0,30 * * * * // setiap meniteCho $ Generator-> Set (baru ButschstercronexpressionPartSminutesEveryMinute ()); // * * * * * echo $ generator-> set (baru ButschstercronexpressionPartSminutesEveryMinute (2)); // * */2 * * * // MinutesechoCho $ Generator-> Set (baru ButschstercronexpressionPartsMinutessPecificMinutes (2, 3, 10)); // * 2,3,10 * * * // Antara menithecho $ Generator-> Set (ButschstercronexpressionPartSminutesbetweenminutes (0, 30)); // * 0-30 * * *
// Setiap jam pada 00 menit $ generator-> jam (); // 0 * * * * // Setiap jam pada 15 menit. // 15 * * * * // Setiap jam pada 15, 30, 45 menit $ generator-> jam (15, 30, 45); // 15,30,45 * * * * // setiap dua jam $ generator-> everytwohours (); // 0 */2 * * * // setiap tiga jam $ generator-> everythehours (); // 0 */3 * * * // setiap empat jam $ generator-> everyfourhours (); // 0 */4 * * * // setiap enam jam $ generator-> EverySixHours (); // 0 */6 * * * // Setiap 1, 2, 3 jam $ Generator-> Set (ButschstercronexpressionPartShoursSpecifichours baru (1, 2, 3)); // * 1,2,3 * * * // setiap tiga jam $ generator-> set (ButschstercronexpressionPartShourSeverYhour ()) baru; // * * * * * echo $ generator-> set (baru ButschstercronexpressionPartShourseveryHour (3)); // * */3 * * * // Antara Hoursecho $ Generator-> Set (baru ButschstercronexpressionPartshoursbetweenhours (0, 12)); // * 0-12 * * *
// setiap hari pada 00: 00echo $ generator-> daily (); // 0 0 * * * // Setiap hari di 01: 00echo $ Generator-> Daily (1); // 0 1 * * * // Setiap hari pada pukul 03:00, 15:00, 23: 00echo $ Generator-> Harian (3, 15, 23); // 0 3,15,23 * * * * // Setiap hari pada 13: 00echo $ Generator-> Doakuat (13); // 0 13 * * * // Setiap hari di 13: 25echo $ Generator-> Doakuat (13, 25); // 25 13 * * * // Setiap hari pada pukul 03:00, 15: 00echo $ Generator-> Twicedaily (3, 15); // 0 3,15 * * * // Setiap hari di 03:05, 15: 05echo $ Generator-> Twicedailyat (3, 15, 5); // 5 3,15 * * * // Setiap bulan pada hari terakhir pada 00: 00echo $ Generator-> lastdayofmonth (); // 0 0 L * * // Setiap bulan pada hari terakhir pukul 12: 00echo $ Generator-> LastDayOfMonth (12); // 0 12 L * * // Setiap bulan pada hari terakhir pada 12: 30echo $ Generator-> LastDayOfmonth (12, 30); // 30 12 L * * // Setiap bulan pada hari kerja terakhir pada 00: 00echo $ generator-> lastweekdayofmonth (); // 0 0 LW * * // Setiap bulan pada hari kerja terakhir pukul 12: 00echo $ generator-> lastweekdayofmonth (12); // 0 12 LW * * // Setiap bulan pada hari kerja terakhir di 12: 30echo $ Generator-> LastWeekdayOf Month (12, 30); // 30 12 LW * * // Setiap 1, 2, 3 hari $ Generator-> Set (ButschstercronexpressionPartsdaysPecificdays baru (1, 2, 3)); // * * 1,2,3 * * echo $ generator-> set (baru ButschstercronexpressionPartsdayseveryday ()); // * * * * * * // Setiap tiga hari $ generator-> set (baru ButschstercronexpressionPartsdayseveryday (3)); // * * */3 * * // Antara Daysecho $ Generator-> Set (BUTSCHSTERCRONEXPRESSIONPARTSDAYSBETWETWEENDAYS (0, 12)); // * * 0-12 * * // Hari terakhir bulan Monthecho $ Generator-> Set (ButschstercronexpressionPartsdaysLastdayOfMonth ()); // * * l * *
// setiap minggu pada hari Senin $ generator-> mingguan (); // 0 0 * * 0 // Setiap minggu pada hari Senin dan Kamis. // 0 0 * * 1,4 // Setiap minggu di hari kerja Secho $ Generator-> Daily ()-> Weekdays (); // 0 0 * * 1-5 // Setiap minggu di Weekendsecho $ Generator-> Daily ()-> Weekends (); // 0 0 * * 6,0 // Setiap Senin $ Generator-> Harian ()-> Senin (); // 0 0 * * 1 // ORECHO $ GENERATOR-> WeeklyOnMonDay (); // ORECHO $ GENERATOR-> WeeklyOnMonDay (8, 6); // 6 8 * * 1 // Setiap Selasa $ Generator-> Daily ()-> Selasa (); // 0 0 * * 2 // ORECHO $ GENERATOR-> WeeklyontuesDay (); // Setiap Rabu $ Generator-> Daily ()-> Rabu (); // 0 0 * * 3 // ORECHO $ GENERATOR-> WeeklyonWednesday (); // Setiap Kamis $ Generator-> Daily ()-> Kamis (); // 0 0 * * 4 // ORECHO $ GENERATOR-> Weeklyonthursday (); // Setiap Jumat $ Generator-> Daily ()-> Friday (); // 0 0 * * 5 // ORECHO $ GENERATOR-> WeeklyOnFriday (); // Setiap Saturdayecho $ Generator-> Daily ()-> Saturdays (); // 0 0 * * 6 // ORECHO $ GENERATOR-> WeeklyonSaturday (); // Setiap Sundayecho $ Generator-> Daily ()-> Sunday (); // 0 0 * * 0 // ORECHO $ GENERATOR-> Weeklyonsunday (); // Setiap Senin $ Generator-> Weeklyon (Generator :: Senin); // 0 0 * * 1 // Setiap Senin pukul 8 pagi Echo $ Generator-> Weeklyon (Generator :: Senin, 8); // 0 8 * * 1 // Setiap Senin di 08: 06echo $ Generator-> Weeklyon (Generator :: Senin, 8, 6); // 6 8 * * 1 // Setiap hari dari A Weekecho $ Generator-> Set (baru ButschstercronexpressionPartsdaysofweekeverydayofweek ()); // * * * * * * // Setiap dua hari dari Weekecho $ Generator-> Set (ButschstercronexpressionPartsdaysofweekeverydayofweek (2)); // * * * * */2 // Setiap Senin, Rabu, Jumat $ Generator-> Set (ButschstercronexpressionPartsdaysofweekspecificdaysofweek (Generator :: Senin, Generator :: Rabu, Generator :: Jumat)); // * * * * 1,3,5 // Antara hari dari A Weekecho $ Generator-> Set (ButschstercronexpressionPartsdaysofweekBetWeendayofweek baru (generator :: Senin, generator :: Jumat)); // * * * * 1-5 // Senin terakhir dari Weekecho $ Generator-> Set (ButschstercronexpressionPartsdaysofweekLasTayOfWeek ()); // * * * * 1l // Jumat terakhir dari Weekecho $ Generator-> Set (ButschstercronexpressionPartsdaysofweekLastdayofweek baru (generator :: Jumat)); // * * * * 5l // Setiap hari Senin pertama setiap bulan $ Generator-> Set (ButschstercronexpressionPartsdaysofweeknthdayofweek ()); // * * * * 1#1 // Setiap hari Jumat ketiga dari setiap bulan $ generator-> set (ButschstercronexpressionPartsdaysofweeknthdayofweek baru (generator :: Jumat, 3)); // * * * * 5#3
// Setiap bulan pada hari 1-STS pada 00: 00echo $ Generator-> Monthly (); // 0 0 1 * * // Setiap bulan pada hari 1-STS pada 12: 00echo $ Generator-> Bulanan (12); // 00 12 1 * * // Setiap bulan pada hari 1-STS pada 12: 30echo $ Generator-> Bulanan (12, 30); // 30 12 1 * * // Setiap bulan pada hari 15-STS pada 12: 00echo $ Generator-> Monthlyon (15, 12); // 0 12 15 * * // Setiap bulan pada hari 15-STS pada 12: 30echo $ Generator-> Monthlyon (15, 12, 30); // 30 12 15 * * // Setiap bulan dua kali pada 15, 24 hari pukul 00: 00echo $ generator-> Twicemonthly (15, 24); // 0 0 15,24 * * // Setiap bulan dua kali pada 15, 24 hari pada 10: 00echo $ generator-> Twicememtly (15, 24, 10); // 0 10 15,24 * * // Setiap bulan dua kali pada 15, 24 hari pada 10: 30echo $ Generator-> Twicemonthly (15, 24, 10, 30); // 30 10 15,24 * * // Setiap bulan tiga kali pada 12, 24, 30 hari pada 10: 345echo $ Generator-> DEARGEAT (10, 45)-> DaysOf Month (12, 24, 30); // 45 10 12,24,30 * * // Setiap kuartal yyyy-01,03,06,09-01 00: 00echo $ Generator-> Quarterly (); // 0 0 1 1-12/3 *// Setiap tahun yyyy-01-01 00: 00echo $ generator-> tahunan (); // 0 0 1 1 *// Setiap tahun yyyy-04-01 00: 00echo $ generator-> tahunan (generator :: apr); // 0 0 1 4 *// Setiap tahun yyyy-04-05 00: 00echo $ generator-> tahunan (generator :: Apr, 5); // 0 0 5 4 *// Setiap tahun yyyy-04-05 08: 00echo $ generator-> tahunan (generator :: Apr, 5, 8); // 0 8 5 4 *// Setiap tahun yyyy-04-05 08: 30echo $ generator-> tahunan (generator :: Apr, 5, 8, 30); // 30 8 5 4 *// Setiap bulan $ Generator-> Set (ButschstercronexpressionPartsmonthSeveryMonth ()) baru; // * * * * * * // Setiap dua bulan $ generator-> set (baru ButschstercronexpressionPartsmonthSeveryMonth (2)); // * * * */2 * // Bulan spesifik: April dan Decemberecho $ Generator-> Set (ButschstercronexpressionPartsmonthsSpecificmonths baru (Generator :: APR, Generator :: Dec)); // * * * 4,12 * // Antara April dan Decemberecho $ Generator-> Set (ButschstercronexpressionPartsmonthsbetweenths (Generator :: Generator :: DEC)); // * * * 4-12 * // Quarterlyecho $ Generator-> Set (ButschstercronexpressionPartsmonthSquarterly ()); // * * * 1-12/3 *
$ date = datetime baru ('2021-02-05 12:34:26'); // Setiap tahun yyyy-02-05 12: 34echo $ generator-> on ($ date); // 34 12 5 2 *// ORECHO $ GENERATOR-> SET (BUTSCHSTERCRONEXPRESTIONPARTSDATETIME ($ DATE)); // 34 12 5 2 *
Gunakan ButschstercronexpressionPartsdayspectifdays; Gunakan ButschstercronexpressionPartsdaysofweekspecificdaysofweek; Gunakan ButschstercronexpressionPartshourseveryhour; ButschstercronexpressionPartSminuteSevelyminute; ButsChMOMMOMMOMMOMMOMMOMMOMMOMMOMMOMMOMMOMMOMITSMINTERMINETEMIT; 5,10,15,20,25,30 3,6,9,12 1,3,5,0echo $ generator-> tahunan () -> Bulan (Generator :: Mar, Generator :: Jun, Generator :: Sep, Generator :: Des) -> Daysofonth (5, 10, 15, 20, 25, 30) -> DaysOfWeek (Generator :: Senin, Generator :: Rabu, Generator :: Jumat, Generator :: Minggu) -> everytwohours () -> EveryMinute (); // ORECHO $ GENERATOR-> SET (Spesifik New Months (Generator :: Mar, Generator :: Jun, Generator :: SEP, GENERATOR :: DEC), Hari Spesifik Baru (5, 10, 15, 20, 25, 30), Spesifik Newsofweek (Generator :: Senin, Generator :: Rabu, Generator :: Jumat, Generator :: Minggu), Everyhour Baru (2), EveryMinute baru () );
Lihat: https://github.com/dragonmantank/cron-expression#usage
Echo $ Generator-> Monthlyon (15, 12)-> getExpression ()-> getNextrundate (); // datetime
<? Phpnamespace AppConsole; Gunakan ButschstercronexpressionGenerator; Gunakan IlluminateConsolesChedulingChedule; Gunakan IlluminateFoundationConsolekernel sebagai konsolekernel; Gunakan Jadwal yang Diproteskan (Jadwal Jadwal (Jadwal $ Jadwal) (Jadwal Jadwal) (Jadwal Jadwal (Jadwal Protected (Jadwal $ Jadwal) (Jadwal Protected (Jadwal $ Jadwal) (Jadwal (Jadwal Jadwal) (Jadwal Protected Class Consolekernel {Jadwal (Jadwal $ Jadwal) {$ jadwal-> perintah ('email: kirim taylor--force')-> cron (generator :: create ()-> daily () ); } }
Untuk membuat kelas ekspresi khusus, Anda perlu menerapkan ButschsterCronExpressionPartValueInterface
Gunakan ButschstercronexpressionPartValueInterface; gunakan croncronexpression; kelas triwulanan mengimplementasikan PartValueTerFace {Public Function UpdateExpression (Cronexpression $ Expression): void {$ ekspresi-> setPart (Cronexpression :: Month, '1-12/3'); } }
Menggunakan
Echo ButschstercronexpressionGenerator :: create ()-> Set (New Quarterly ()); // * * * 1-12/3 *
Gunakan ButschstercronexpressionPartsdayspectifdays; Gunakan ButschstercronexpressionPartShoursSpecifichours; menggunakan ButschstercronexpressionPartSminutessPecificMinutes; menggunakan ButschstercronPartSmontSpecificmineTs; menggunakan ButschstercronpressionPartSmineSpecificminTHS; menggunakan ButschtercroneCronPartSMOnTHSpecificMonths; DateTimeInterface; kelas Datetime mengimplementasikan PartValueInterface {Fungsi Publik __Construct (Private DateTimeInterface $ Time) { } Fungsi publik updateExpression (cronexpression $ ekspresi): void {$ parts = [new spesifik new ((int) $ this-> time-> format ('i')), specifichours baru ((int) $ this-> time-> format ('g')), format spesifik baru ((int) $ this-> time-> format ('j')), baru Format spesifik ((int) $ this-> time-> format ('n')) ]; foreach ($ bagian sebagai $ bagian) {$ part-> updateExpression ($ ekspresi); } } }
Menggunakan
Echo ButschstercronexpressionGenerator :: create ()-> set (datetime baru (datetime baru ('2021-02-05 12:34:26')))); // 34 12 5 2 *
Tes Komposer
Butschster
Lisensi MIT (MIT). Silakan lihat file lisensi untuk informasi lebih lanjut.