Skip to content

Commit

Permalink
Merge pull request #6 from myaaghubi/v1.5
Browse files Browse the repository at this point in the history
V1.5
  • Loading branch information
myaaghubi committed May 11, 2024
2 parents 242e1e0 + 415c54e commit 4a40c58
Show file tree
Hide file tree
Showing 33 changed files with 1,541 additions and 322 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Testing
on: [push, pull_request]
jobs:
tests:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ["8.1", "8.2", "8.3"]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
coverage: pcov

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

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress

- name: Test with phpunit
run: vendor/bin/phpunit --configuration phpunit.xml --coverage-text

- name: Make code coverage badge
uses: coverallsapp/github-action@v2
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
vendor
build
composer.lock
.phpunit.cache
theme
index.php
coverage.xml
clover.xml
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Debench
[![Test Debench](https://github.com/myaaghubi/Debench/actions/workflows/ci.yml/badge.svg)](https://github.com/myaaghubi/Debench/actions/workflows/ci.yml) [![Debench Coverage Status](https://coveralls.io/repos/github/myaaghubi/Debench/badge.svg?branch=main)](https://coveralls.io/github/myaaghubi/Debench?branch=main) ![Debench release (latest by date)](https://img.shields.io/github/v/release/myaaghubi/Debench) ![Debench License](https://img.shields.io/github/license/myaaghubi/Debench)

A small debug/benchmark helper for PHP

Expand All @@ -19,34 +20,38 @@ require __DIR__ . '/vendor/autoload.php';

// call it from your index.php after autoload
// then check the webpage with your browser
// $debench = new Debench();
Debench::getInstance();
// $debench = new Debench(true, 'theme');
Debench::getInstance(true, 'theme');

$st = str_repeat("Debench!", 10000);

// step one
// $debench->newPoint("step one");
Debench::point('step one');
// $debench->newPoint("one");
Debench::point('one');

$st .= str_repeat("Debench!", 10000);

// step two
Debench::point("step two");
Debench::info('step two');
Debench::point("two");
```
For `minimal` mode:
```php
$debench->setMinimal(true);
// it is safe and secure to use for production mode
// $debench->setMinimalOnly(true);
Debench::minimalOnly(true);
```
For `production` mode
```php
// this one is better
$debench = new Debench(false);
// it's better to do it on initializing
//$debench = new Debench(false);
Debench::getInstance(false);
// or
$debench->setEnable(false);
Debench::enable(false);
```

## License

You are allowed to use this plugin under the terms of the MIT License.

Copyright (C) 2024 Mohammad Yaaghubi
Copyright (C) 2024 Mohammad Yaaghubi
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
],
"autoload": {
"classmap": [
"lib/"
"lib/Debench"
]
},
"autoload-dev": {
"classmap": [
"lib/DebenchTest"
]
},
"require-dev": {
Expand Down
Loading

0 comments on commit 4a40c58

Please sign in to comment.