Skip to content

Commit f94b3bb

Browse files
committed
CakePHP Scheduling plugin. Initial version
0 parents  commit f94b3bb

70 files changed

Lines changed: 9088 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 4
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.yml]
15+
indent_size = 2
16+
17+
[phars.xml]
18+
indent_size = 2
19+
20+
[*.neon]
21+
indent_style = tab

.gitattributes

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Define the line ending behavior of the different file extensions
2+
# Set default behaviour, in case users don't have core.autocrlf set.
3+
* text=auto
4+
* text eol=lf
5+
6+
# Explicitly declare text files we want to always be normalized and converted
7+
# to native line endings on checkout.
8+
*.php text
9+
*.default text
10+
*.ctp text
11+
*.md text
12+
*.po text
13+
*.js text
14+
*.css text
15+
*.ini text
16+
*.txt text
17+
*.xml text
18+
19+
# Declare files that will always have CRLF line endings on checkout.
20+
*.bat eol=crlf
21+
22+
# Declare files that will always have LF line endings on checkout.
23+
*.pem eol=lf
24+
25+
# Denote all files that are truly binary and should not be modified.
26+
*.png binary
27+
*.jpg binary
28+
*.gif binary
29+
*.ico binary
30+
*.mo binary
31+
32+
# Remove files for archives generated using `git archive`
33+
.editorconfig export-ignore
34+
.gitattributes export-ignore
35+
.gitignore export-ignore
36+
.stickler.yml export-ignore
37+
.travis.yml export-ignore
38+
CONTRIBUTING.md export-ignore
39+
Dockerfile export-ignore
40+
docs.Dockerfile export-ignore
41+
phpcs.xml.dist export-ignore
42+
phpstan.neon export-ignore
43+
phpunit.xml.dist export-ignore
44+
psalm.xml export-ignore
45+
/.github export-ignore
46+
/tests export-ignore

.github/pull_request_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Description
2+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
3+
4+
## Type of change
5+
Please delete options that are not relevant.
6+
7+
- [ ] Bug fix (non-breaking change which fixes an issue)
8+
- [ ] New feature (non-breaking change which adds functionality)
9+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10+
- [ ] Documentation update
11+
- [ ] Code refactoring
12+

.github/workflows/ci.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- '*'
8+
9+
jobs:
10+
testsuite:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php-version: ['8.2', '8.3', '8.4']
16+
os: [ubuntu-latest, windows-latest]
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-version }}
24+
extensions: mbstring, intl
25+
coverage: pcov
26+
27+
- name: Cache composer dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.composer/cache
31+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
32+
33+
- name: composer install
34+
run: composer install --prefer-dist --no-progress
35+
36+
- name: Setup problem matchers for PHPUnit
37+
if: matrix.php-version == '8.2' && matrix.os == 'ubuntu-latest'
38+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
39+
40+
- name: Run PHPUnit with coverage
41+
if: matrix.php-version == '8.2' && matrix.os == 'ubuntu-latest'
42+
run: |
43+
export CODECOVERAGE=1
44+
vendor/bin/phpunit --configuration=phpunit.xml --display-deprecations --display-incomplete --display-skipped --coverage-clover=coverage.xml
45+
46+
- name: Run PHPUnit without coverage
47+
if: matrix.php-version != '8.2' || matrix.os != 'ubuntu-latest'
48+
run: vendor/bin/phpunit --configuration=phpunit.xml
49+
50+
- name: Submit code coverage
51+
if: matrix.php-version == '8.2' && matrix.os == 'ubuntu-latest'
52+
uses: codecov/codecov-action@v3
53+
54+
cs-stan:
55+
name: Coding Standard & Static Analysis
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Setup PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: '8.2'
65+
extensions: mbstring, intl
66+
coverage: none
67+
tools: phive
68+
69+
- name: Cache composer dependencies
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.composer/cache
73+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
74+
75+
- name: composer install
76+
run: composer install --prefer-dist --no-progress
77+
78+
- name: Install phive
79+
run: |
80+
wget -O phive.phar https://phar.io/releases/phive.phar
81+
chmod +x phive.phar
82+
sudo mv phive.phar /usr/local/bin/phive
83+
84+
- name: Install PHP tools with phive
85+
run: |
86+
phive install --trust-gpg-keys CF1A108D0E7AE720,51C67305FFC2E5C0,12CE0F1D262429A5
87+
88+
- name: Run PHP CodeSniffer
89+
run: composer cs-check
90+
91+
- name: Run phpstan
92+
run: composer stan

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# User specific & automatically generated files #
2+
#################################################
3+
/build
4+
/dist
5+
/tags
6+
/composer.lock
7+
/tools
8+
/vendor
9+
/tmp
10+
*.mo
11+
debug.log
12+
error.log
13+
/tests/test_app/config/Create/*
14+
/tests/test_app/config/Queue/*
15+
/tests/test_app/config/TestsQueue/schema-dump-test.lock
16+
/tests/test_app/Plugin/TestBlog/config/Queue/*
17+
.phpunit.cache
18+
19+
# IDE and editor specific files #
20+
#################################
21+
/nbproject
22+
.idea
23+
24+
# OS generated files #
25+
######################
26+
.DS_Store
27+
.DS_Store?
28+
._*
29+
.Spotlight-V100
30+
.Trashes
31+
Icon?
32+
ehthumbs.db
33+
Thumbs.db
34+
/.phpunit.result.cache

.phive/phars.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="phpstan" version="2.1.17" installed="2.1.17" location="./tools/phpstan" copy="false"/>
4+
<phar name="psalm" version="6.12.0" installed="6.12.0" location="./tools/psalm" copy="false"/>
5+
</phive>

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Evgeny Tomenko
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Scheduling Plugin
2+
3+
The **Scheduling** plugin provides comprehensive task scheduling for CakePHP applications with the following features:
4+
5+
The scheduler allows you to fluently and expressively define your command schedule within your CakePHP application itself. When using the scheduler, only a single cron entry is needed on your server. Your task schedule is defined during your application's container building phase using CakePHP's event system.
6+
7+
The plugin provides task scheduling capabilities with sub-minute precision, allowing you to schedule tasks as frequently as every second. It features a fluent API for defining task frequencies from seconds to yearly intervals, with human-readable syntax that makes complex schedules easy to understand and maintain.
8+
9+
Task overlap prevention ensures that long-running tasks don't interfere with subsequent executions, while single-server execution prevents duplicate task runs in multi-server environments. Background task execution allows multiple tasks to run simultaneously, improving overall system performance.
10+
11+
The plugin includes comprehensive task hooks for before, after, success, and failure callbacks, enabling you to implement custom logic around task execution. Repeatable tasks with configurable intervals provide flexibility for tasks that need to run multiple times within a minute.
12+
13+
The plugin integrates seamlessly with CakePHP's console system and event manager.
14+
15+
## Requirements
16+
17+
* PHP 8.2+
18+
* SignalHandler Plugin (for graceful termination)
19+
20+
See [Versions.md](Docs/Versions.md) for the supported CakePHP versions.
21+
22+
## Documentation
23+
24+
For documentation, as well as tutorials, see the [Docs](docs/Home.md) directory of this repository.
25+
26+
## License
27+
28+
Licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.

composer.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "skie/cakephp-scheduling",
3+
"description": "CakePHP Scheduling manager",
4+
"type": "cakephp-plugin",
5+
"license": "MIT",
6+
"require": {
7+
"php": ">=8.2",
8+
"cakephp/cakephp": "^5.0",
9+
"dragonmantank/cron-expression": "^3.3.2",
10+
"symfony/process": "^6.0",
11+
"skie/signal_handler": "^1.0"
12+
},
13+
"require-dev": {
14+
"phpunit/phpunit": "^10.0",
15+
"cakephp/cakephp-codesniffer": "^4.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Scheduling\\": "src/"
20+
}
21+
},
22+
"autoload-dev": {
23+
"psr-4": {
24+
"Scheduling\\Test\\": "tests/",
25+
"TestApp\\": "tests/TestApp/src",
26+
"TestPlugin\\": "tests/test_app/plugins/TestPlugin/src/"
27+
}
28+
},
29+
"scripts": {
30+
"cs-check": "phpcs -p --standard=phpcs.xml src/ tests/",
31+
"cs-fix": "phpcbf --standard=phpcs.xml src/ tests/",
32+
"test": "phpunit",
33+
"test:unit": "phpunit --testsuite=Unit",
34+
"test:integration": "phpunit --testsuite=Integration",
35+
"test:coverage": "phpunit --coverage-html coverage",
36+
"stan": "tools/phpstan analyse src/",
37+
"psalm": "tools/psalm --show-info=false",
38+
"stan-tests": "tools/phpstan analyze -c tests/phpstan.neon",
39+
"stan-baseline": "tools/phpstan --generate-baseline"
40+
},
41+
"extra": {
42+
"installer-name": "Scheduling"
43+
},
44+
"config": {
45+
"allow-plugins": {
46+
"dealerdirect/phpcodesniffer-composer-installer": true
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)