Skip to content

Commit

Permalink
README changes and config file
Browse files Browse the repository at this point in the history
  • Loading branch information
insign committed Mar 7, 2024
1 parent 0abea95 commit 82f1efe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
```
# Progressable
# Progressable 🚀

A Laravel [(not only)](#without-laravel) package to track and manage progress for different tasks or processes.

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/verseles/progressable/phpunit.yml?style=for-the-badge&label=PHPUnit)

## Installation

You can install the package via composer:
Install the package via Composer:

```bash
composer require verseles/progressable
Expand All @@ -19,25 +18,27 @@ Optionally, you can publish the config file with:
php artisan vendor:publish --provider="Verseles\Progressable\ProgressableServiceProvider" --tag="config"
```

The options of the published config file:
## Configuration

The published config file provides the following options:

```php
return [
'ttl' => env('PROGRESSABLE_TTL', 1140),
'ttl' => env('PROGRESSABLE_TTL', 1140), // Default cache time-to-live (in minutes)

'prefix' => env('PROGRESSABLE_PREFIX', 'progressable'),
'prefix' => env('PROGRESSABLE_PREFIX', 'progressable'), // Cache key prefix
];
```

## Usage

This package provides a main class (a trait): `Progressable`.
This package provides a main trait: `Progressable`.

### With Laravel

The `Progressable` trait can be used in any class that needs to track progress. It provides two main methods: `updateLocalProgress` and `getLocalProgress`.

"Local" because anytime you can get "Overall" progress calling `getOverallProgressData()`. Local is your class/model/etc progress and Overall is the sum of all Progressable classes using the same key name.
"Local" refers to the progress of your class/model/etc, while "Overall" represents the sum of all Progressable classes using the same key name.

### Example
```php
Expand Down Expand Up @@ -86,17 +87,17 @@ class MySecondTask
}
```

* Use the `setOverallUniqueName` method to associate the progress of the class with a specific overall progress instance
* `setLocalProgress` method updates the progress for the current instance.
* `getLocalProgress` method retrieves the current progress.
* `getOverallProgress` method retrieves the overall progress data.
* `resetOverallProgress` is good to be called after set unique name for the first time in your first class if your progress will run more then once to avoid wrong calculations in cache.
- Use `setOverallUniqueName` to associate the progress with a specific overall progress instance.
- `setLocalProgress` updates the progress for the current instance.
- `getLocalProgress` retrieves the current progress.
- `getOverallProgress` retrieves the overall progress data.
- `resetOverallProgress` resets the overall progress (recommended after setting the unique name for the first time).

The progress value ranges from 0 to 100.

### Without Laravel

You can use the `Progressable` trait without Laravel. You need to provide a custom save and get data methods.
You can use the `Progressable` trait without Laravel by providing custom save and get data methods.

### Example

Expand Down Expand Up @@ -133,7 +134,7 @@ $obj2

## Testing

You can run the tests with:
To run the tests, execute the following command:

```bash
make
Expand All @@ -142,4 +143,3 @@ make
## License

The Progressable package is open-sourced software licensed under the [MIT license](./LICENSE.md).
```
9 changes: 9 additions & 0 deletions config/progressable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@

'ttl' => env('PROGRESSABLE_TTL', 1140),

/*
|--------------------------------------------------------------------------
| Cache Prefix
|--------------------------------------------------------------------------
|
| This option specifies the default prefix for the progress data.
|
*/

'prefix' => env('PROGRESSABLE_PREFIX', 'progressable'),
];

0 comments on commit 82f1efe

Please sign in to comment.