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
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/.github export-ignore
/docs export-ignore
/examples export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/phpstan.neon.dist export-ignore

# Configure diff output for .php and .phar files.
*.php diff=php
*.phar -diff
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
74 changes: 74 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# When a PR is opened or a push is made, perform
# a static analysis check on the code using PHPStan.
name: PHPStan

on:
pull_request:
branches:
- 'develop'
paths:
- 'src/**'
- 'tests/**'
- 'composer.**'
- 'phpstan*'
- '.github/workflows/analyze.yml'
push:
branches:
- 'develop'
paths:
- 'src/**'
- 'tests/**'
- 'composer.**'
- 'phpstan*'
- '.github/workflows/analyze.yml'

jobs:
build:
name: PHP ${{ matrix.php-versions }} Static Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.3', '7.4', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer, pecl, phpunit
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Create composer cache directory
run: mkdir -p ${{ steps.composer-cache.outputs.dir }}

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Create PHPStan cache directory
run: mkdir -p build/phpstan

- name: Cache PHPStan results
uses: actions/cache@v2
with:
path: build/phpstan
key: ${{ runner.os }}-phpstan-${{ github.sha }}
restore-keys: ${{ runner.os }}-phpstan-

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- name: Run static analysis
run: vendor/bin/phpstan analyze
80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: PHPUnit

on:
pull_request:
branches:
- develop
push:
branches:
- develop

jobs:
main:
name: PHP ${{ matrix.php-versions }} Unit Tests

strategy:
matrix:
php-versions: ['7.3', '7.4', '8.0']

runs-on: ubuntu-latest

if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer, pecl, phpunit
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3
coverage: xdebug

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- name: Test with PHPUnit
run: vendor/bin/phpunit --verbose --coverage-text
env:
TERM: xterm-256color

- if: matrix.php-versions == '8.0'
name: Mutate with Infection
run: |
composer global require infection/infection
git fetch --depth=1 origin $GITHUB_BASE_REF
infection --threads=2 --skip-initial-tests --coverage=build/phpunit --git-diff-base=origin/$GITHUB_BASE_REF --git-diff-filter=AM --logger-github --ignore-msi-with-no-mutations

- if: matrix.php-versions == '8.0'
name: Run Coveralls
run: vendor/bin/php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }}

coveralls:
needs: [main]
name: Coveralls Finished
runs-on: ubuntu-latest
steps:
- name: Upload Coveralls results
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ vendor/
build/
phpunit*.xml
phpunit
*.cache
composer.lock
.DS_Store
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,12 @@ in your `<head>` tag or use the **Assets** config file to load them for certain

If you install assets manually be sure to include Bootstrap.

## Configuration (optional)
### Authentication

The library's default behavior can be altered by extending its config file. Copy
**examples/Chat.php** to **app/Config/** and follow the instructions
in the comments. If no config file is found in **app/Config** the library will use its own.

### Accounts

**Chat** uses `Tatter\Accounts` to determine participants username and display name. By default
the **Myth:Auth** handler is active, but you can specify any handler (see
[instructions on GitHub](https://github.com/tattersoftware/codeigniter4-accounts)) or make
**Chat** uses `Tatter\Users` to determine participants username and display name. You must
be sure to include a package that provides `codeigniter4/authentication-implementation`,
like **Myth:Auth** or make your own (see [Authentication](https://codeigniter4.github.io/CodeIgniter4/extending/authentication.html)
for framework requirements).
your own.

## Usage
Expand All @@ -86,4 +81,4 @@ a random UID (e.g. for a one-time site visitor).
Conversations are stored and loaded from the database with the `ConversationModel`, and
most of the logic is handled by the Entities. For example, use a `Conversation` entity can
`$conversation->addUser($userId)` to join or refresh a user and get back a `Participant`.
A `Participant` can `$participant->say('hello world')` to add a `Message`.
A `Participant` can `$participant->say('hello world')` to add a `Message`.
54 changes: 29 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "tatter/chat",
"type": "library",
"description": "Embedded chat widget for CodeIgniter 4",
"keywords": [
"codeigniter",
Expand All @@ -17,45 +18,48 @@
"role": "Developer"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/codeigniter4/CodeIgniter4"
},
{
"type": "vcs",
"url": "https://github.com/lonnieezell/myth-auth"
}
],
"minimum-stability": "dev",
"require": {
"php" : ">=7.2",
"php": "^7.3 || ^8.0",
"codeigniter4/authentication-implementation": "1.0",
"components/jquery": "^3.3",
"twbs/bootstrap": "^4.3",
"tatter/accounts": "^1.0",
"tatter/assets": "^2.0"
"tatter/assets": "^2.0",
"tatter/users": "^1.0",
"twbs/bootstrap": "^4.3"
},
"require-dev": {
"phpunit/phpunit" : "^7.0",
"mockery/mockery": "^1.0",
"fzaninotto/faker": "^1.9@dev",
"codeigniter4/codeigniter4": "dev-develop",
"myth/auth": "dev-develop"
"myth/auth": "dev-develop",
"tatter/tools": "^1.6"
},
"autoload": {
"psr-4": {
"Tatter\\Chat\\": "src"
}
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
},
"autoload-dev": {
"psr-4": {
"ModuleTests\\Support\\": "tests/_support"
"Tests\\Support\\": "tests/_support"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/codeigniter4/CodeIgniter4"
},
{
"type": "vcs",
"url": "https://github.com/lonnieezell/myth-auth"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"test": "phpunit",
"post-update-cmd": [
"composer dump-autoload"
]
"analyze": "phpstan analyze",
"mutate": "infection --threads=2 --skip-initial-tests --coverage=build/phpunit",
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 tests/ src/",
"test": "phpunit"
}
}
17 changes: 0 additions & 17 deletions examples/Chat.php

This file was deleted.

19 changes: 19 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"source": {
"directories": [
"src"
],
"excludes": [
"Config",
"Database/Migrations",
"Views"
]
},
"logs": {
"text": "build/infection.log"
},
"mutators": {
"@default": true
},
"bootstrap": "vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php"
}
25 changes: 25 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
parameters:
tmpDir: build/phpstan
level: 5
paths:
- src
- tests
bootstrapFiles:
- vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php
excludes_analyse:
- src/Config/Routes.php
- src/Views/*
ignoreErrors:
- '#Call to an undefined static method Config\\Services::[A-Za-z]+\(\)#'
- '#Cannot access property [\$a-z_]+ on (array|object)#'
- '#Cannot call method [\$A-Za-z_]+\(\) on (array|object)#'
universalObjectCratesClasses:
- CodeIgniter\Entity
- Faker\Generator
scanDirectories:
- vendor/codeigniter4/codeigniter4/system/Helpers
- vendor/myth/auth/src/Helpers
dynamicConstantNames:
- APP_NAMESPACE
- CI_DEBUG
- ENVIRONMENT
Loading