Skip to content

Commit

Permalink
Merge pull request #3 from Label84/laravel9
Browse files Browse the repository at this point in the history
Laravel 9 support
  • Loading branch information
tjardoo authored Feb 7, 2022
2 parents 32100e1 + 62ac405 commit 652b4d4
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 295 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.18.6
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs --allow-risky=yes
args: --config=.php_cs.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v1

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [7.4, 8.0, 8.1]
laravel: [8.*]
php: [8.0, 8.1]
laravel: [9.*]
dependency-version: [prefer-stable]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
composer.phar
composer.lock
.php_cs.cache
.phpunit.result.cache
.DS_Store
/.idea
/.vscode
/.vscode
.phpunit.result.cache
.php-cs-fixer.cache
145 changes: 0 additions & 145 deletions .php_cs

This file was deleted.

39 changes: 39 additions & 0 deletions .php_cs.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__.'/src',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to `laravel-mailviewer` will be documented in this file.

## 3.0 - 2022-02-07

- Laravel 9 support (Symfony Mailer)

## 2.0 - 2021-12-22

- N/A

## 1.0 - 2020-12-22

- Initial release
48 changes: 15 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,40 @@
[![Total Downloads](https://img.shields.io/packagist/dt/label84/laravel-mailviewer.svg?style=flat-square)](https://packagist.org/packages/label84/laravel-mailviewer)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/label84/laravel-mailviewer/run-tests?label=Tests&style=flat-square)

Laravel MailViewer enables you to view and filter mail that is sent by your Laravel application. It saves all sent mail to the database automatically. It also includes an overview page with the total number of mails sent grouped by Notification.
With ``laravel-mailviewer`` you can view and filter mail that is sent by your Laravel application in the browser. The package saves all mails sent to the database automatically.
You can get get an overview of all mails sent, view individual mails and get an overview of the number of mails sent grouped by Notification.

![MailViewer screenshot](./docs/screenshot_default.png?raw=true "MailViewer Screenshot")

- [Requirements](#requirements)
- [Laravel support](#laravel-support)
- [Installation](#installation)
- [Usage](#usage)
- [Query filters](#query-filters)
- [Filters](#Filters)
- [Analytics](#analytics)
- [Examples](#examples)
- [Commands](#commands)
- [Exclude records](#exclude-records)
- [Tests](#tests)
- [Security](#security)
- [License](#license)

## Requirements

- Laravel 7.x or 8.x
- Laravel 8.x or 9.x
- PHP >=7.4 or 8.x

## Laravel support

| Version | Release |
|---------|---------|
| 9.x | ^3.0 |
| 8.x | ^2.0 |
| 7.x | ^1.0 |

## Limitations

This package is only able to track mails send via [SwiftMailer library](https://swiftmailer.symfony.com). By default Laravel uses this library when sending mails via [Mailables](https://laravel.com/docs/8.x/mail) and [Notifications](https://laravel.com/docs/8.x/notifications).
This package tracks mails sent via [Symfony Mailer](https://symfony.com/doc/current/mailer). Laravel 9 uses this library by default when sending mails via [Mailables](https://laravel.com/docs/master/mail) and [Notifications](https://laravel.com/docs/master/notifications).

With the upgrade to Laravel 9 the SwiftMailer has been replaced with Symfony Mailer [Upgrade Symfony Mailer](https://laravel.com/docs/master/upgrade#symfony-mailer). To add this package to a Laravel 8 application you have to use version ``^2.0`` of this package - ``composer require "label84/laravel-mailviewer:^2.0"``.

## Installation

Expand All @@ -49,26 +51,14 @@ Add the package to your application:
composer require label84/laravel-mailviewer
```

You can also manually update your composer.json.

### 2. Install package

Add the config and migration to your application.

```sh
php artisan mailviewer:install
```

#### 2.1 Install package manually (alternative)

You can also install the package manually by executing the following two commands.
### 2. Publish the config file and migration

```sh
php artisan vendor:publish --provider="Label84\MailViewer\MailViewerServiceProvider" --tag="config"
php artisan vendor:publish --provider="Label84\MailViewer\MailViewerServiceProvider" --tag="migrations"
```

#### 2.2 Publish the views (optional)
#### 2.1 Publish the views (optional)

To change the default views, you can publish them to your application.

Expand All @@ -86,13 +76,9 @@ php artisan migrate

## Usage

To preview the mails sent by your application visit: ``/admin/mailviewer``

You can change the url in the config file.
To preview the mails sent by your application visit: ``/admin/mailviewer``. You can change this url in the config file.

To view the content of the mail you can click on the UUID (blue link).

### Query filters
### Filters

You can filter the mails in the overview with query parameters - example ``/admin/mailviewer?notification=WelcomeMail``.

Expand All @@ -114,9 +100,9 @@ The around parameter show all mails sent around the given time. By default is wi

![MailViewer Analytics screenshot](./docs/screenshot_analytics.png?raw=true "MailViewer Analytics Screenshot")

To preview the analytics page visit: ``/admin/mailviewer/analytics``
To preview the analytics page visit: ``/admin/mailviewer/analytics``. You can change this url in the config file.

You can change the route in the config file.
On the analytics page you can view the number of mails sent per Notification and see how long ago the latest Notification was sent.

### Examples

Expand All @@ -142,7 +128,7 @@ php artisan mailviewer:cleanup --days=30

### Exclude records

In the config file you can add an array of notification classes and an array of email addresses that should be excluded. Those notifications and email addresses won't be saved to the database.
In the config file you can add an array of Notification classes and an array of email addresses that should be excluded. Those notifications and email addresses won't be saved to the database.

## Tests

Expand All @@ -151,10 +137,6 @@ composer analyse
composer test
```

## Security

By default the package only applies the 'web and 'auth' middleware to the routes. When used in production make sure you apply additional middleware or other security measures to restrict access.

## License

[MIT](https://opensource.org/licenses/MIT)
Loading

0 comments on commit 652b4d4

Please sign in to comment.