Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
exclude_paths:
- "tests/**"
11 changes: 0 additions & 11 deletions .codeclimate.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bulk formatting commits, ignored by `git blame` (git config blame.ignoreRevsFile .git-blame-ignore-revs).
# Apply PER-CS coding style
ec049c8404c0eb7f7d470f6781429133857bc6c8
7 changes: 4 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/.github export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.git-blame-ignore-revs export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpunit.xml export-ignore
/README.md export-ignore
/.codeclimate.yml export-ignore
/.scrutinizer.yml export-ignore
/.codacy.yml export-ignore
16 changes: 10 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
- package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
push:
branches: [develop, master]
pull_request:

permissions:
contents: read

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

jobs:
tests:
name: Tests (PHP ${{ matrix.php }}, ${{ matrix.dependencies }} deps)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
dependencies: [highest]
include:
- php: '8.3'
dependencies: lowest
steps:
- uses: actions/checkout@v5

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

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

- run: vendor/bin/phpunit

coding-style:
name: Coding style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- uses: ramsey/composer-install@v3

- run: vendor/bin/php-cs-fixer fix --dry-run --diff
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ composer.lock
.htaccess
bin
build
.phpunit.cache
.php-cs-fixer.cache
tests/urlMap.cache
10 changes: 10 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([__DIR__ . '/src', __DIR__ . '/tests']);

return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
])
->setFinder($finder);
41 changes: 0 additions & 41 deletions .scrutinizer.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# RestServer.php
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jk/RestServer/badges/quality-score.png?s=f73d03bf31d39ae6d8e6717e59fb37ee9f070a2e)](https://scrutinizer-ci.com/g/jk/RestServer/)
[![Code Coverage](https://scrutinizer-ci.com/g/jk/RestServer/badges/coverage.png?s=04bcecf088febc189f3e7f876802def3bd7a5e16)](https://scrutinizer-ci.com/g/jk/RestServer/)
[![CI](https://github.com/jk/RestServer/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/jk/RestServer/actions/workflows/ci.yml)
[![Latest Stable Version](https://poser.pugx.org/jk/restserver/v/stable.svg)](https://packagist.org/packages/jk/restserver)
[![License](https://poser.pugx.org/jk/restserver/license.svg)](https://packagist.org/packages/jk/restserver)
[![Total Downloads](https://poser.pugx.org/jk/restserver/downloads.svg)](https://packagist.org/packages/jk/restserver)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/efa0c47d-3ffa-4fc8-b456-18d2edd29851/mini.png)](https://insight.sensiolabs.com/projects/efa0c47d-3ffa-4fc8-b456-18d2edd29851)
[![Documentation Status](https://readthedocs.org/projects/restserver/badge/?version=develop)](https://readthedocs.org/projects/restserver/?badge=develop)

| Master branch | Develop branch |
| :---: | :---: |
[![Master Build Status](https://travis-ci.org/jk/RestServer.svg?branch=master)](https://travis-ci.org/jk/RestServer)|[![Develop Build Status](https://travis-ci.org/jk/RestServer.svg?branch=develop)](https://travis-ci.org/jk/RestServer)
A PHP REST server for providing a very light-weight REST API. Very easy to set
up and get going. Independent from other libraries and frameworks. Supports
HTTP authentication.

A PHP REST server for providing a very light-weight REST API. Very easy to set up and get going. Independent from other libraries and frameworks. Supports HTTP authentication. Supports AMF data if the Zend Framework is present for Flash clients.
As of [Classification of HTTP-based APIs][classification] this implementation
should be considered as an HTTP based type II type of an API. So it is not an
academic version of a real RESTful API, but this is by intention, so it's easy
to understand and install.

As of [Classification of HTTP-based APIs](https://algermissen.io/classification_of_http_apis.html) this implementation should be considered as an HTTP based type II type of an API. So it is not an academic version of a real RESTful API, but this is by intention, so it's easy to understand and install.
[classification]: https://algermissen.io/classification_of_http_apis.html

## Development

Requires PHP 8.3 or newer.

```sh
composer install
composer test # run the PHPUnit test suite
composer cs # check coding style (PER-CS)
composer cs-fix # fix coding style
```
29 changes: 19 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,36 @@
"type": "library",
"description": "A PHP REST server for providing a very light-weight REST API without aweful routing configuration",
"require": {
"php": "^5.6|~7|~8",
"php": "^8.3",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*"
},
"require-dev": {
"phpunit/phpunit": "~4|~0",
"mockery/mockery": ">=0.9.3",
"fabpot/php-cs-fixer": "~1|~0",
"squizlabs/php_codesniffer": "~2|~0",
"codeclimate/php-test-reporter": "dev-master"
"phpunit/phpunit": "^12.0",
"friendsofphp/php-cs-fixer": "^3.64"
},
"suggest": {
"ext-simplexml": "*"
},
"autoload": {
"psr-0": {
"JK\\RestServer\\": "src/",
"psr-4": {
"JK\\RestServer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"JK\\RestServer\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit",
"cs": "php-cs-fixer fix --dry-run --diff",
"cs-fix": "php-cs-fixer fix"
},
"config": {
"sort-packages": true
},
"homepage": "https://github.com/jk/RestServer",
"license": "MIT",
"authors": [
Expand All @@ -35,7 +44,7 @@
}
],
"support": {
"issues": "https://github.com/jk/restserver/issues",
"wiki": "https://github.com/jk/restserver/wiki"
"issues": "https://github.com/jk/RestServer/issues",
"wiki": "https://github.com/jk/RestServer/wiki"
}
}
34 changes: 12 additions & 22 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/Bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="tests/Bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnPhpunitDeprecations="true">
<testsuites>
<testsuite name="jk/restserver unit tests">
<directory>tests</directory>
Expand All @@ -22,14 +17,9 @@
<group>disabled</group>
</exclude>
</groups>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<source>
<include>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml" logIncompleteSkipped="true" />
</logging>

</include>
</source>
</phpunit>
28 changes: 0 additions & 28 deletions sami_config.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace JK\RestServer;

/**
Expand All @@ -7,7 +8,6 @@
*/
class DocBlockParser
{

/**
* Get doc keys from a method's docblock documentation
*
Expand All @@ -18,14 +18,14 @@ public static function getDocKeys(\ReflectionMethod $reflection_method)
{
$doc_comment_string = $reflection_method->getDocComment();

$keys_as_array = array('url');
$keys_as_array = ['url'];
/**
* The following RegExpr captures @annotation. It must start with an @ symbol following by a word of one or more
* charaters. Optionally followed by a space or a tab and a string. And all these annotations must end in
* a proper new line (\n, \r\n etc.) to seperate the findings.
*/
if (preg_match_all('/@(\w+)([ \t](.*?))?(?:\n|\r)+/', $doc_comment_string, $matches, PREG_SET_ORDER)) {
$keys = array();
$keys = [];
foreach ($matches as $match) {
if (in_array($match[1], $keys_as_array)) {
$keys[$match[1]][] = $match[3];
Expand Down
Loading
Loading