Skip to content

Commit

Permalink
Initial Code Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Jan 22, 2018
1 parent 50a974c commit d2bff91
Show file tree
Hide file tree
Showing 16 changed files with 4,656 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.json]
indent_size = 2

[Makefile]
indent_style = tab
11 changes: 11 additions & 0 deletions .gitattributes
@@ -0,0 +1,11 @@
# Ignoring files for distribution archieves
examples/ export-ignore
tests/ export-ignore
.dunitconfig export-ignore
.travis.yml export-ignore
.gitignore export-ignore
.gitattributes export-ignore
.scrutinizer.yml export-ignore
.styleci.yml export-ignore
appveyor.yml export-ignore
phpunit.xml.dist export-ignore
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
examples/credentials.php
vendor/
21 changes: 21 additions & 0 deletions .php_cs
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

use ApiClients\Tools\TestUtilities\PhpCsFixerConfig;
use PhpCsFixer\Config;

return (function (): Config
{
$paths = [
__DIR__ . DIRECTORY_SEPARATOR . 'src',
__DIR__ . DIRECTORY_SEPARATOR . 'tests',
];

return PhpCsFixerConfig::create()
->setFinder(
PhpCsFixer\Finder::create()
->in($paths)
->append($paths)
)
->setUsingCache(false)
;
})();
68 changes: 68 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,68 @@
filter:
paths: [src/*]
excluded_paths: [examples/*, tests/*]
tools:
external_code_coverage: true
php_analyzer: true
php_hhvm: true
php_sim: true
php_pdepend: true
sensiolabs_security_checker: true
php_changetracking: true
php_code_sniffer:
enabled: true
config:
tab_width: 0
encoding: utf8
ruleset: ~
standard: "PSR2"
php_cs_fixer:
enabled: true
config:
level: psr2
php_mess_detector:
enabled: true
config:
ruleset: ~
code_size_rules:
cyclomatic_complexity: true
npath_complexity: true
excessive_method_length: true
excessive_class_length: true
excessive_parameter_list: true
excessive_public_count: true
too_many_fields: true
too_many_methods: true
excessive_class_complexity: true
design_rules:
exit_expression: true
eval_expression: true
goto_statement: true
number_of_class_children: true
depth_of_inheritance: true
coupling_between_objects: true
unused_code_rules:
unused_private_field: true
unused_local_variable: true
unused_private_method: true
unused_formal_parameter: true
naming_rules:
short_variable:
minimum: 3
long_variable:
maximum: 20
short_method:
minimum: 3
constructor_conflict: true
constant_naming: true
boolean_method_name: true
controversial_rules:
superglobals: true
camel_case_class_name: true
camel_case_property_name: true
camel_case_method_name: true
camel_case_parameter_name: true
camel_case_variable_name: true
checks:
php:
code_rating: true
66 changes: 66 additions & 0 deletions .travis.yml
@@ -0,0 +1,66 @@
language: php

## Cache composer bits
cache:
directories:
- $HOME/.composer/cache/files

## Build matrix for lowest and highest possible targets
matrix:
include:
- php: 7.0
env:
- qaExtended=true
- php: 7.1
- php: 7.2
env:
- dropPlatform=false
- php: nightly
env:
- dropPlatform=false
- php: 7.0
env:
- dependencies=lowest
- php: 7.1
env:
- dependencies=lowest
- php: 7.2
env:
- dependencies=lowest
- dropPlatform=false
- php: nightly
env:
- dependencies=lowest
- dropPlatform=false
- php: 7.0
env:
- dependencies=highest
- php: 7.1
env:
- dependencies=highest
- php: 7.2
env:
- dependencies=highest
- dropPlatform=false
- php: nightly
env:
- dependencies=highest
- dropPlatform=false

## Install or update dependencies
install:
- composer validate
- if [ -z "$dropPlatform" ]; then composer config --unset platform.php; fi;
- if [ -z "$qaExtended" ]; then phpenv config-rm xdebug.ini || :; fi;
- if [ -z "$dependencies" ]; then composer install --prefer-dist; fi;
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-dist -n; fi;
- if [ "$dependencies" = "highest" ]; then composer update --prefer-dist -n; fi;
- composer show

## Run the actual test
script:
- if [ -z "$qaExtended" ]; then make ci; fi;
- if [ "$qaExtended" = "true" ]; then make ci-extended; fi;

## Gather coverage and set it to coverage servers
after_script: if [ "$qaExtended" = "true" ]; then make ci-coverage; fi;
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,38 @@
# Contributing

Pull requests are highly appreciated. Here's a quick guide.

Fork, then clone the repo:

git clone git@github.com:your-username/reactphp-http-middleware-session.git

Set up your machine:

composer install

Make sure the tests pass:

make unit

Make your change. Add tests for your change. Make the tests pass:

make unit

Before committing and submitting your pull request make sure it passes PSR2 coding style, unit tests pass and pass on all supported PHP versions:

make contrib

Push to your fork and [submit a pull request][pr].

[pr]: https://help.github.com/articles/creating-a-pull-request/

At this point you're waiting on me. I like to at least comment on pull requests
within a day or two. I may suggest some changes or improvements or alternatives.

Some things that will increase the chance that your pull request is accepted:

* Write tests.
* Follow PSR2 (travis will also check for this).
* Write a [good commit message][commit].

[commit]: http://chris.beams.io/posts/git-commit/
32 changes: 32 additions & 0 deletions Makefile
@@ -0,0 +1,32 @@
all:
composer run-script qa-all --timeout=0

all-coverage:
composer run-script qa-all-coverage --timeout=0

ci:
composer run-script qa-ci --timeout=0

ci-extended:
composer run-script qa-ci-extended --timeout=0

contrib:
composer run-script qa-contrib --timeout=0

init:
composer ensure-installed

cs:
composer cs

cs-fix:
composer cs-fix

unit:
composer run-script unit --timeout=0

unit-coverage:
composer run-script unit-coverage --timeout=0

ci-coverage: init
composer ci-coverage
53 changes: 52 additions & 1 deletion README.md
@@ -1 +1,52 @@
# reactphp-http-middleware-session
# Middleware that takes care of session handling

[![Build Status](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-session.svg?branch=master)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-session)
[![Latest Stable Version](https://poser.pugx.org/WyriHaximus/react-http-middleware-session/v/stable.png)](https://packagist.org/packages/WyriHaximus/react-http-middleware-session)
[![Total Downloads](https://poser.pugx.org/WyriHaximus/react-http-middleware-session/downloads.png)](https://packagist.org/packages/WyriHaximus/react-http-middleware-session)
[![Code Coverage](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-http-middleware-session/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-http-middleware-session/?branch=master)
[![License](https://poser.pugx.org/WyriHaximus/react-http-middleware-session/license.png)](https://packagist.org/packages/WyriHaximus/react-http-middleware-session)
[![PHP 7 ready](http://php7ready.timesplinter.ch/WyriHaximus/reactphp-http-middleware-clear-body/badge.svg)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-clear-body)

# Install

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require wyrihaximus/react-http-middleware-session
```

This middleware removes the raw body from the request. Best used after the request body has been parsed.

# Usage

```php
$server = new Server([
/** Other Middleware */
new SessionMiddleware('CookieName', $cache),
/** Other Middleware */
]);
```

# License

The MIT License (MIT)

Copyright (c) 2018 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions appveyor.yml
@@ -0,0 +1,56 @@
build: false
platform:
- x64
clone_folder: c:\projects\php-project-workspace

## Build matrix for lowest and highest possible targets
environment:
matrix:
- dependencies: lowest
php_ver_target: 7.0
- dependencies: lowest
php_ver_target: 7.1
- dependencies: current
php_ver_target: 7.0
- dependencies: current
php_ver_target: 7.1
- dependencies: highest
php_ver_target: 7.0
- dependencies: highest
php_ver_target: 7.1

## Cache composer file
cache:
- '%LOCALAPPDATA%\Composer\files -> composer.lock'

## Set up environment varriables
init:
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH%
- SET COMPOSER_NO_INTERACTION=1
- SET PHP=1
- SET ANSICON=121x90 (121x90)

## Install PHP and composer, and run the appropriate composer command
install:
- IF EXIST c:\tools\php (SET PHP=0)
- ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','')
- cd c:\tools\php
- IF %PHP%==1 copy php.ini-production php.ini /Y
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
- IF %PHP%==1 echo extension_dir=ext >> php.ini
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
- cd c:\projects\php-project-workspace
- composer config --unset platform.php
- IF %dependencies%==lowest appveyor-retry composer update --prefer-lowest --no-progress --profile -n
- IF %dependencies%==current appveyor-retry composer install --no-progress --profile
- IF %dependencies%==highest appveyor-retry composer update --no-progress --profile -n
- composer show

## Run the actual test
test_script:
- cd c:\projects\php-project-workspace
- vendor/bin/phpunit -c phpunit.xml.dist

0 comments on commit d2bff91

Please sign in to comment.