Skip to content

Commit

Permalink
Improve php dependencies support
Browse files Browse the repository at this point in the history
* Add PHP 8.2 support
  • Loading branch information
Fernando Marcelino committed Apr 12, 2023
1 parent 5ed64a4 commit e2c4f91
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
php: [ "8.0", "8.1" ]
php: [ "8.0", "8.1", "8.2" ]
runs-on: ubuntu-latest

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coverage.xml
.php_cs.cache
examples/lumen-app/vendor
.phpunit.cache
.phpunit.result.cache
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Laravel (and Lumen) Prometheus Exporter

## Version Compatibility

| Releases | PHP |
|:---------|:-------|
| 3.x | ^8.1; |
| 4.x | ^8.2; |

A prometheus exporter package for Laravel and Lumen.

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
Expand All @@ -23,6 +30,34 @@ library's functionality and the way it's intended to be used.

## Installation

### Laravel 10

#### Install via composer
Run the following command:
```bash
composer require arquivei/laravel-prometheus-exporter
```

#### Add service provider
Add the service provider to the `providers` array in the `config/app.php` config file as follows:
```bash
'providers' => [

...

Arquivei\LaravelPrometheusExporter\PrometheusServiceProvider::class,
]
```

#### Publish the config
Run the following command:
```bash
php artisan vendor:publish --provider="Arquivei\LaravelPrometheusExporter\PrometheusServiceProvider"
```
You should now have a `config/prometheus.php`.


### Laravel 9 or below
Add the repository to composer.json
```composer.json
"repositories": [
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
}
],
"require": {
"php": "^8.0 || ^8.1",
"php": "^8.0 || ^8.1 || ^8.2",
"guzzlehttp/guzzle": "^7.4.2",
"illuminate/routing": "^9.0",
"illuminate/support": "^9.0",
"illuminate/routing": "^9.0 || ^10.0",
"illuminate/support": "^9.0 || ^10.0",
"promphp/prometheus_client_php": "^2.6.0"
},
"require-dev": {
Expand Down
23 changes: 11 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
verbose="true"
colors="true">

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
displayDetailsOnTestsThatTriggerNotices="true"
colors="true"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
Expand Down
3 changes: 2 additions & 1 deletion src/PrometheusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private function loadRoutes()

private function configPath($path) : string
{
return $this->app->basePath() . ($path ? DIRECTORY_SEPARATOR . $path : '');
$basePath = sprintf('%s/%s', $this->app->basePath(), 'config');
return $basePath . ($path ? DIRECTORY_SEPARATOR . $path : '');
}
}

0 comments on commit e2c4f91

Please sign in to comment.