Skip to content

Commit e55fa73

Browse files
committed
Merge branch '2.x'
2 parents d4583b8 + c7c1ab8 commit e55fa73

31 files changed

+815
-239
lines changed

.github/workflows/ci.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# CI workflow adapted from https://github.com/cakephp/cakephp/blob/master/.github/workflows/ci.yml
2+
name: CI
3+
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
testsuite:
10+
runs-on: ubuntu-24.04
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php-version: ['8.2', '8.3', '8.4']
15+
db-type: [sqlite, mysql, pgsql]
16+
prefer-lowest: ['']
17+
18+
steps:
19+
- name: Setup MySQL latest
20+
if: matrix.db-type == 'mysql'
21+
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin
22+
23+
- name: Setup PostgreSQL latest
24+
if: matrix.db-type == 'pgsql'
25+
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres
26+
27+
- uses: actions/checkout@v4
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-version }}
33+
extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }}
34+
ini-values: apc.enable_cli = 1
35+
coverage: pcov
36+
37+
- name: Get composer cache directory
38+
id: composer-cache
39+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
40+
41+
- name: Get date part for cache key
42+
id: key-date
43+
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
44+
45+
- name: Cache composer dependencies
46+
uses: actions/cache@v4
47+
with:
48+
path: ${{ steps.composer-cache.outputs.dir }}
49+
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
50+
51+
- name: Composer install
52+
run: |
53+
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
54+
composer update --prefer-lowest --prefer-stable
55+
else
56+
composer update
57+
fi
58+
59+
- name: Setup problem matchers for PHPUnit
60+
if: matrix.php-version == '8.2' && matrix.db-type == 'mysql'
61+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
62+
63+
- name: Run PHPUnit
64+
run: |
65+
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
66+
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi
67+
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
68+
if [[ ${{ matrix.php-version }} == '8.2' ]]; then
69+
export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=coverage.xml --configuration phpunit.xml.dist
70+
else
71+
vendor/bin/phpunit --configuration phpunit.xml.dist
72+
fi
73+
74+
- name: Submit code coverage
75+
if: matrix.php-version == '8.2'
76+
uses: codecov/codecov-action@v4
77+
78+
cs:
79+
name: Coding Standard
80+
runs-on: ubuntu-24.04
81+
82+
steps:
83+
- uses: actions/checkout@v4
84+
85+
- name: Setup PHP
86+
uses: shivammathur/setup-php@v2
87+
with:
88+
php-version: '8.2'
89+
extensions: mbstring, intl, apcu, memcached, redis
90+
tools: cs2pr
91+
coverage: none
92+
93+
- name: Get composer cache directory
94+
id: composer-cache
95+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
96+
97+
- name: Get date part for cache key
98+
id: key-date
99+
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
100+
101+
- name: Cache composer dependencies
102+
uses: actions/cache@v4
103+
with:
104+
path: ${{ steps.composer-cache.outputs.dir }}
105+
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
106+
107+
- name: composer install
108+
run: composer install
109+
110+
- name: Run PHP CodeSniffer
111+
run: composer cs-check
112+
continue-on-error: true

LICENSE.txt

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

README.md

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
1-
# CakephpEnqueue plugin for CakePHP
1+
CakePHP Enqueue Plugin
2+
=======================
23

3-
## Installation
4+
[![Build Status](https://img.shields.io/github/workflow/status/cakedc/cakephp-enqueue/CI/master?style=flat-square)](https://github.com/cakedc/cakephp-enqueue/actions?query=workflow%3ACI+branch%3Amaster)
5+
[![Downloads](https://poser.pugx.org/cakedc/cakephp-enqueue/d/total.png)](https://packagist.org/packages/cakedc/cakephp-enqueue)
6+
[![Latest Version](https://poser.pugx.org/cakedc/cakephp-enqueue/v/stable.png)](https://packagist.org/packages/cakedc/cakephp-enqueue)
7+
[![License](https://poser.pugx.org/cakedc/cakephp-enqueue/license.svg)](https://packagist.org/packages/cakedc/cakephp-enqueue)
48

5-
You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).
9+
Versions and branches
10+
---------------------
611

7-
The recommended way to install composer packages is:
12+
| CakePHP | CakePHP Enqueue Plugin | Tag | Notes |
13+
| :-------------: | :------------------------: | :--: | :---- |
14+
| ^5.1 | [2.x](https://github.com/CakeDC/cakephp-enqueue/tree/2.x) | 2.0.1 | stable |
15+
| ^4.5 | [1.x](https://github.com/CakeDC/cakephp-enqueue/tree/1.x) | 1.0.0 | stable |
816

9-
```
10-
composer require your-name-here/cakephp-enqueue
11-
```
17+
The **CakePHP Enqueue** plugin provides message queue integration for CakePHP applications using the Enqueue library and database as a message broker.
18+
19+
Requirements
20+
------------
21+
22+
* CakePHP 4.5+ or 5.1+
23+
* PHP 8.0+
24+
25+
Documentation
26+
-------------
27+
28+
For documentation, see the [Docs](docs/index.md) directory of this repository.
29+
30+
Support
31+
-------
32+
33+
For bugs and feature requests, please use the [issues](https://github.com/cakedc/cakephp-enqueue/issues) section of this repository.
34+
35+
Contributing
36+
------------
37+
38+
This repository follows the [CakeDC Plugin Standard](https://www.cakedc.com/plugin-standard). If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our [Contribution Guidelines](https://www.cakedc.com/contribution-guidelines) for detailed instructions.
39+
40+
License
41+
-------
42+
43+
Copyright 2022 Cake Development Corporation (CakeDC). All rights reserved.
44+
45+
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
"type": "cakephp-plugin",
55
"license": "MIT",
66
"require": {
7-
"php": ">=7.2",
8-
"cakephp/queue": "*",
9-
"cakephp/cakephp": "^4.3"
7+
"php": ">=8.2",
8+
"cakephp/queue": "^2.0",
9+
"cakephp/cakephp": "^5.1",
10+
"cakephp/migrations": "^4.0"
1011
},
1112
"require-dev": {
12-
"cakephp/cakephp-codesniffer": "^4.0",
13+
"cakephp/cakephp-codesniffer": "^5.0",
1314
"enqueue/enqueue": "^0.10.15",
1415
"enqueue/fs": "^0.10",
1516
"enqueue/simple-client": "^0.10",
16-
"psr/log": "^1.1",
17-
"phpunit/phpunit": "^8.5 || ^9.3"
17+
"psr/log": "^3.0",
18+
"phpunit/phpunit": "^10.0"
1819
},
1920
"autoload": {
2021
"psr-4": {

docs/index.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Home
2+
====
3+
4+
The **CakePHP Enqueue** plugin provides message queue integration for CakePHP applications and uses database as a message broker.
5+
6+
Quick Start
7+
-----------
8+
9+
1. Install the plugin:
10+
11+
```bash
12+
composer require cakedc/cakephp-enqueue
13+
```
14+
15+
2. Load the plugin in your `Application.php`:
16+
17+
```php
18+
$this->addPlugin('CakephpEnqueue');
19+
```
20+
21+
3. Configure your queue in `config/app.php`:
22+
23+
```php
24+
'Queue' => [
25+
'default' => [
26+
'url' => 'cakephp://default?table_name=queue'
27+
]
28+
]
29+
```
30+
31+
4. Create a job:
32+
33+
```php
34+
use App\Job\ExampleJob;
35+
use Cake\Queue\QueueManager;
36+
37+
$data = ['id' => 7, 'is_premium' => true];
38+
$options = ['config' => 'default'];
39+
40+
QueueManager::push(ExampleJob::class, $data, $options);
41+
```
42+
43+
5. Process jobs:
44+
45+
```bash
46+
bin/cake queue:worker
47+
```
48+
49+
DSN Configuration
50+
-----------------
51+
52+
The plugin supports standard DSN format:
53+
- `cakephp://connection_name?table_name=queue&polling_interval=1000`

phpunit.xml.dist

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
colors="true"
5+
processIsolation="false"
6+
stopOnFailure="false"
7+
displayDetailsOnTestsThatTriggerDeprecations="true"
8+
displayDetailsOnTestsThatTriggerErrors="true"
9+
displayDetailsOnTestsThatTriggerNotices="true"
10+
displayDetailsOnTestsThatTriggerWarnings="true"
11+
beStrictAboutOutputDuringTests="true"
12+
bootstrap="tests/bootstrap.php"
13+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
814
<php>
915
<ini name="memory_limit" value="-1"/>
1016
<ini name="apc.enable_cli" value="1"/>
@@ -15,8 +21,14 @@
1521
<directory>tests/TestCase/</directory>
1622
</testsuite>
1723
</testsuites>
18-
<!-- Setup fixture extension -->
19-
<extensions>
20-
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension"/>
21-
</extensions>
24+
25+
<coverage>
26+
<include>
27+
<directory suffix=".php">src/</directory>
28+
</include>
29+
<exclude>
30+
<directory suffix=".php">tests/</directory>
31+
<directory suffix=".php">vendor/</directory>
32+
</exclude>
33+
</coverage>
2234
</phpunit>

0 commit comments

Comments
 (0)