Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
71aa6ea
chore: update ignore files
Levdbas Mar 23, 2026
e3e7183
chore: remove travis
Levdbas Mar 23, 2026
7906be1
test: update testing framework
Levdbas Mar 23, 2026
59001f4
docs: update badges and formatting
Levdbas Mar 23, 2026
60cee78
test: update xml config
Levdbas Mar 23, 2026
9229e6c
Refactor code structure for improved readability and maintainability
Levdbas Mar 23, 2026
f4680e5
feat: add GitHub Actions for PHP setup, coding standards, linting, an…
Levdbas Mar 23, 2026
0276308
chore: lint files
Levdbas Mar 23, 2026
e785b77
refactor: enhance code structure and improve documentation for the Ro…
Levdbas Mar 23, 2026
5517cbc
chore: move files
Levdbas Mar 23, 2026
5aad532
chore: update PHP requirement to 8.2 in composer.json
Levdbas Mar 23, 2026
6691c98
chore: add mantle-framework/support dependency and update PHP platfor…
Levdbas Mar 23, 2026
55ceebf
chore: add mantle-framework/contracts dependency to composer.json
Levdbas Mar 23, 2026
7e3c912
chore: update composer/installers dependency version in composer.json…
Levdbas Mar 23, 2026
322c698
chore: add mantle-framework/container dependency to composer.json and…
Levdbas Mar 23, 2026
1063eea
chore: replace strpos with str_starts_with for improved readability a…
Levdbas Mar 23, 2026
8488f8b
chore: update composer.json and composer.lock to include additional m…
Levdbas Mar 23, 2026
25cd6ab
chore: update phpunit.xml to correct path for Routes.php file inclusion
Levdbas Mar 23, 2026
17937e8
chore: remove PHP coding standards workflow file
Levdbas Mar 23, 2026
1662929
chore: update .gitattributes to export-ignore .github directory
Levdbas Mar 23, 2026
4eb3698
chore: remove unused Timber plugin functions from bootstrap file
Levdbas Mar 23, 2026
5d790ee
chore: initialize matches_class_test array in RoutesTest for class ro…
Levdbas Mar 23, 2026
4e5b8b8
Update Routes.php
Levdbas Mar 23, 2026
ee06993
Update Routes.php
Levdbas Mar 23, 2026
e697225
Update .gitattributes
Levdbas Mar 23, 2026
6e20f1b
fix: correct spelling of 'Preceeding' to 'Preceding' in testVerySimpl…
Levdbas Mar 23, 2026
442c262
fix: update branch references from '2.x' to 'master' in PHP lint work…
Levdbas Mar 23, 2026
0a8fa98
Refactor code structure for improved readability and maintainability
Levdbas Mar 23, 2026
73cb1ce
fix: update template filter callback to include current template para…
Levdbas Mar 23, 2026
6210e94
fix: enhance parameter descriptions in load method for clarity
Levdbas Mar 23, 2026
108a002
fix: reset matches_class_test array before assertions in class route …
Levdbas Mar 23, 2026
bc9c354
fix: replace strpos with str_contains for better readability in conve…
Levdbas Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

/bin export-ignore
/tests export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.coveralls.yml export-ignore
/phpunit.xml export-ignore
/README.md export-ignore
/readme.txt export-ignore
/ecs.php export-ignore
/rector.php export-ignore
40 changes: 40 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Setup PHP & Composer"
description: "Setup PHP & installs composer dependencies"
inputs:
PHP_VERSION:
description: PHP version
default: "8.2"
required: false
type: string
PHP_TOOLS:
description: PHP version
default: ""
required: false
type: string
COMPOSER_ARGS:
description: Set of arguments passed to Composer.
default: "--prefer-dist --no-scripts"
required: false
type: string
INSTALL_DEPS:
description: Whether to install dependencies or not.
default: true
required: false
type: boolean

runs:
using: composite
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.PHP_VERSION }}
tools: ${{ format('composer,{0}', inputs.PHP_TOOLS) }}
- name: Remove lock file
shell: bash
run: rm -f composer.lock
Comment thread
Levdbas marked this conversation as resolved.
- name: Install Composer dependencies
if: ${{ inputs.INSTALL_DEPS == 'true' }}
uses: ramsey/composer-install@v3
with:
composer-options: ${{ inputs.COMPOSER_ARGS }}
46 changes: 46 additions & 0 deletions .github/workflows/php-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PHP lint

on:
push:
branches:
- master
paths:
- "**.php"
- "**composer.json"
pull_request:
branches:
- master
paths:
- "**.php"
- "**composer.json"
types:
- opened
- synchronize
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
php-lint:
name: PHP lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install dependencies
uses: ./.github/actions/setup
with:
PHP_TOOLS: "parallel-lint,cs2pr"
INSTALL_DEPS: false

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v47
with:
files: "**.php"

- name: Run PHP lint
if: steps.changed-files.outputs.all_changed_files != ''
run: parallel-lint --exclude .git --exclude vendor --checkstyle ${{ join(steps.changed-files.outputs.all_changed_files, ' ') }} | cs2pr
41 changes: 41 additions & 0 deletions .github/workflows/php-rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PHP Rector

on:
push:
branches:
- master
paths:
- "**.php"
- "**composer.json"
pull_request:
branches:
- master
paths:
- "**.php"
- "**composer.json"
types:
- opened
- synchronize
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
php-cs:
name: PHP Rector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install dependencies
uses: ./.github/actions/setup

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v47

- name: Run Rector checks
if: steps.changed-files.outputs.all_changed_files != ''
run: ./vendor/bin/rector process --dry-run ${{ steps.changed-files.outputs.files }}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow checks all_changed_files in the if: condition, but the run: command uses steps.changed-files.outputs.files, which isn’t produced by tj-actions/changed-files (so Rector may run with an empty file list). Use the same all_changed_files output (optionally filtered to PHP files) in the Rector command.

Suggested change
run: ./vendor/bin/rector process --dry-run ${{ steps.changed-files.outputs.files }}
run: ./vendor/bin/rector process --dry-run ${{ steps.changed-files.outputs.all_changed_files }}

Copilot uses AI. Check for mistakes.
114 changes: 114 additions & 0 deletions .github/workflows/php-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: PHP unit tests

on:
push:
branches:
- master
paths:
- "**workflows/php-unit-tests.yml"
- "**.php"
- "**composer.*"
- "**phpunit.xml"
pull_request:
branches:
- master
paths:
- "**workflows/php-unit-tests.yml"
Comment thread
Levdbas marked this conversation as resolved.
- "**.php"
- "**composer.*"
- "**phpunit.xml"
types:
- opened
- synchronize
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# =============================================================================
# Detect PHP versions from composer.json
# =============================================================================
php-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.versions.outputs.version }}
steps:
- uses: actions/checkout@v6
- id: versions
uses: WyriHaximus/github-action-composer-php-versions-in-range@v1
with:
upcomingReleases: true

# =============================================================================
# Compatibility tests: PHP versions x WP versions
# =============================================================================
php-unit-tests:
needs: php-versions
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.php-versions.outputs.versions) }}
wp: ["latest"]
dependency-version: ["highest", "lowest"]
experimental: [false]
coverage: [false]
include:
# Oldest supported WP with lowest deps
- php: "8.2"
wp: "6.3"
dependency-version: "lowest"
experimental: false
coverage: false
# Coverage: PHP 8.2, WP latest, highest deps
- php: "8.2"
wp: "latest"
dependency-version: "highest"
experimental: false
coverage: true
# Trunk (experimental)
- php: "8.5"
wp: "trunk"
dependency-version: "highest"
experimental: true
coverage: false

name: PHP ${{ matrix.php }} | WP ${{ matrix.wp }} | ${{ matrix.dependency-version }}${{ matrix.coverage && ' | coverage' || '' }}

steps:
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage && 'pcov' || 'none' }}
tools: composer:v2
extensions: curl, date, dom, iconv, json, libxml, gd, sqlite3
ini-values: ${{ matrix.coverage && 'pcov.directory=src' || '' }}

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- uses: ramsey/composer-install@v4
with:
dependency-versions: ${{ matrix.dependency-version }}

# PHP 8.5: Collision and curl have deprecations we can't fix
- name: Disable failOnDeprecation for PHP 8.5
if: matrix.experimental
run: sed -i 's/failOnDeprecation="true"/failOnDeprecation="false"/' phpunit.xml

- name: Create coverage directory
if: matrix.coverage
run: mkdir -p build/logs

- name: Run default testsuite
run: composer test ${{ matrix.coverage && '-- --coverage-php build/coverage-default.cov' || '' }}
env:
WP_VERSION: ${{ matrix.wp }}
36 changes: 21 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# osx noise
!/src/Cache
.tmp
*~

# OS
.DS_Store
profile

# xcode noise
build/*
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata
# IDE and local environment
.idea
.vscode
*.swp

# svn & cvs
.svn
CVS
# Packages
vendor
composer.lock
# Application
build
/cache
twig-cache/*

# Tests
.phpunit.result.cache
/wp-content
/tmp
/.phpunit.cache
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Routes
Simple routing for WordPress. Designed for usage with [Timber](https://github.com/timber/timber)

[![Build Status](https://img.shields.io/travis/Upstatement/routes/master.svg?style=flat-square)](https://travis-ci.org/Upstatement/routes)
[![Coverage Status](https://img.shields.io/coveralls/Upstatement/routes.svg?style=flat-square)](https://coveralls.io/r/Upstatement/routes?branch=master)
[![Packagist Downloads](https://img.shields.io/packagist/dt/Upstatement/routes.svg?style=flat-square)]()
Simple routing for WordPress. Designed for usage with [Timber](https://github.com/timber/timber)

[![PHP unit tests](https://github.com/Upstatement/routes/actions/workflows/php-unit-tests.yml/badge.svg?branch=2.x)](https://github.com/Upstatement/routes/actions/workflows/php-unit-tests.yml?query=branch:2.x)
[![Latest Stable Version](https://img.shields.io/packagist/v/Upstatement/routes.svg?style=flat-square)](https://packagist.org/packages/Upstatement/routes)

### Basic Usage

```php
/* functions.php */
Routes::map('myfoo/bar', 'my_callback_function');
Expand All @@ -21,6 +21,7 @@ Routes::map('my-events/:event', function($params) {
Using routes makes it easy for you to implement custom pagination — and anything else you might imagine in your wildest dreams of URLs and parameters. OMG so easy!

## Some examples

In your functions.php file, this can be called anywhere (don't hook it to init or another action or it might be called too late)

```php
Expand Down Expand Up @@ -77,12 +78,13 @@ my-users/:userid/edit
A function that should fire when the pattern matches the request. Callback takes one argument which is an array of the parameters passed in the URL.

So in this example: `'info/:name/page/:pg'`, $params would have data for:
* `$data['name']`
* `$data['pg']`

- `$data['name']`
- `$data['pg']`

... which you can use in the callback function as a part of your query

* * *
---

## load

Expand Down
Loading
Loading