Skip to content

Commit

Permalink
Merge pull request #148 from onlime/4.x
Browse files Browse the repository at this point in the history
Major overhaul for a possible 4.x release, twilio/sdk 8.x
  • Loading branch information
onlime authored Nov 26, 2024
2 parents 761d57b + f90ab62 commit ec8d4b1
Show file tree
Hide file tree
Showing 31 changed files with 516 additions and 405 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.editorconfig export-ignore
/tests export-ignore
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on: [push, pull_request]

jobs:
phplint:
runs-on: ubuntu-latest

name: PHP Linting (Pint)

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

- name: "laravel-pint"
uses: aglipanci/laravel-pint-action@latest
with:
preset: laravel
verboseMode: true
testMode: true
configPath: "pint.json"
pintVersion: 1.18.2
onlyDirty: true

test:
runs-on: ubuntu-latest
strategy:
max-parallel: 15
fail-fast: false
matrix:
php: [8.3, 8.2]
laravel: [11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*

name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xdebug
coverage: xdebug

- name: Install dependencies
run: |
composer require "illuminate/support:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest
- name: Lint composer.json
run: composer validate

- name: Run Tests
run: composer test:unit

- name: Run Integration Tests
run: composer test:integration
48 changes: 0 additions & 48 deletions .github/workflows/php.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ phpunit.phar

# build
build

# laravel/pint
.pint.cache.json
21 changes: 0 additions & 21 deletions .scrutinizer.yml

This file was deleted.

1 change: 0 additions & 1 deletion .styleci.yml

This file was deleted.

15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Changelog

All notable changes to `twilio` will be documented in this file
All notable changes to `laravel-notification-channels/twilio` will be documented in this file.

## 4.0.0

- Added PHP Linting (Pint) to CI workflow
- Additional tests to achieve 100% code coverage by @pascalbaljet
- Update PhpUnit to 10.5 and fixed all tests.
- Bump `twilio/sdk` to 8.3
- Improved types and use constructor property promotion everywhere.
- Added Pint and fixed PHP syntax.
- Drop support for PHP < 8.2 **BREAKING CHANGE**
- Drop support for Laravel 7.x, 8.x, 9.x, and 10.x **BREAKING CHANGE**
- Enable overriding the Twilio message source #142
- Add enabled config option (`TWILIO_ENABLED`) to disable the channel #21

## 3.0.0

Expand Down
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# Twilio notifications channel for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/twilio.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/twilio)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/github/workflow/status/laravel-notification-channels/twilio/PHP?style=flat-square)](https://travis-ci.org/laravel-notification-channels/twilio)
[![StyleCI](https://styleci.io/repos/65543339/shield)](https://styleci.io/repos/65543339)
[![Quality Score](https://img.shields.io/scrutinizer/g/laravel-notification-channels/twilio.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/twilio)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/twilio/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/twilio/?branch=master)
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/twilio.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/twilio)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/twilio.svg)](https://packagist.org/packages/laravel-notification-channels/twilio)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)
[![Build Status](https://github.com/laravel-notification-channels/twilio/actions/workflows/ci.yml/badge.svg)](https://github.com/laravel-notification-channels/twilio/actions/workflows/ci.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/twilio.svg)](https://packagist.org/packages/laravel-notification-channels/twilio)

This package makes it easy to send [Twilio notifications](https://documentation.twilio.com/docs) with Laravel 5.5+, 6.x, 7.x, 8.x & 9.x

You are viewing the `3.x` documentation. [Click here](https://github.com/laravel-notification-channels/twilio/tree/2.x) to view the `2.x` documentation.
This package makes it easy to send [Twilio notifications](https://documentation.twilio.com/docs) with Laravel 11.x

## Contents

Expand All @@ -26,10 +21,10 @@ You are viewing the `3.x` documentation. [Click here](https://github.com/laravel

## Installation

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

``` bash
composer require laravel-notification-channels/twilio
$ composer require laravel-notification-channels/twilio
```

### Configuration
Expand Down Expand Up @@ -58,7 +53,7 @@ Run `php artisan vendor:publish --provider="NotificationChannels\Twilio\TwilioPr
#### Suppressing specific errors or all errors

Publish the config using the above command, and edit the `ignored_error_codes` array. You can get the list of
exception codes from [the documentation](https://www.twilio.com/docs/api/errors).
exception codes from [the documentation](https://www.twilio.com/docs/api/errors).

If you want to suppress all errors, you can set the option to `['*']`. The errors will not be logged but notification
failed events will still be emitted.
Expand All @@ -70,15 +65,19 @@ Twilio recommends always using a [Messaging Service](https://www.twilio.com/docs

Having issues with SMS? Check Twilio's [best practices](https://www.twilio.com/docs/sms/services/services-best-practices).

## Upgrading from 3.x to 4.x

We have dropped support for PHP < 8.2 and the minimum Laravel version is now 11. Other than that, there are no breaking changes.

## Upgrading from 2.x to 3.x

If you're upgrading from version `2.x`, you'll need to make sure that your set environment variables match those above
in the config section. None of the environment variable names have changed, but if you used different keys in your
If you're upgrading from version `2.x`, you'll need to make sure that your set environment variables match those above
in the config section. None of the environment variable names have changed, but if you used different keys in your
`services.php` config then you'll need to update them to match the above, or publish the config file and change the
`env` key.

You should also remove the old entry for `twilio` from your `services.php` config, since it's no longer used.

The main breaking change between `2.x` and `3.x` is that failed notification will now throw an exception unless they are
in the list of ignored error codes (publish the config file to edit these).

Expand Down Expand Up @@ -188,14 +187,16 @@ $ composer test

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Credits

- [Philip Iezzi (Pipo)](https://github.com/onlime)
- [Pascal Baljet](https://github.com/pascalbaljet)
- [Gregorio Hernández Caso](https://github.com/gregoriohc)
- [atymic](https://github.com/atymic)
- [All Contributors](../../contributors)
Expand Down
29 changes: 18 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
"source": "https://github.com/laravel-notification-channels/twilio"
},
"authors": [
{
"name": "Philip Iezzi",
"email": "[email protected]",
"homepage": "https://github.com/onlime",
"role": "Developer"
},
{
"name": "Gregorio Hernández Caso",
"email": "[email protected]",
Expand All @@ -29,17 +35,18 @@
}
],
"require": {
"php": ">=7.2|^8.0",
"twilio/sdk": "~6.0|^7.16",
"illuminate/notifications": "^7.0 || ^8.0 || ^9.0 || ^10.0|^11.0",
"illuminate/support": "^7.0 || ^8.0 || ^9.0 || ^10.0|^11.0",
"illuminate/events": "^7.0 || ^8.0 || ^9.0 || ^10.0|^11.0",
"illuminate/queue": "^7.0 || ^8.0 || ^9.0 || ^10.0|^11.0"
"php": "^8.2",
"twilio/sdk": "^7.16 || ^8.3",
"illuminate/notifications": "^11.0",
"illuminate/support": "^11.0",
"illuminate/events": "^11.0",
"illuminate/queue": "^11.0"
},
"require-dev": {
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^8.5|^9.5|^10.5",
"orchestra/testbench": "^5.0 || ^6.0 || ^7.0 || ^8.0|^9.0"
"laravel/pint": "^1.18",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
Expand All @@ -53,8 +60,8 @@
},
"scripts": {
"test": "vendor/bin/phpunit",
"test:unit": "phpunit --verbose --testsuite Unit",
"test:integration": "phpunit --verbose --testsuite Integration"
"test:unit": "phpunit --testsuite Unit",
"test:integration": "phpunit --testsuite Integration"
},
"config": {
"sort-packages": true
Expand Down
3 changes: 2 additions & 1 deletion config/twilio-notification-channel.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php

return [
'enabled' => (bool) env('TWILIO_ENABLED', true),
'username' => env('TWILIO_USERNAME'), // optional when using auth token
'password' => env('TWILIO_PASSWORD'), // optional when using auth token
'auth_token' => env('TWILIO_AUTH_TOKEN'), // optional when using username and password
'account_sid' => env('TWILIO_ACCOUNT_SID'),

'from' => env('TWILIO_FROM'), // optional
'alphanumeric_sender' => env('TWILIO_ALPHA_SENDER'),
'shorten_urls' => env('TWILIO_SHORTEN_URLS', false), // optional, enable twilio URL shortener
'shorten_urls' => (bool) env('TWILIO_SHORTEN_URLS', false), // optional, enable twilio URL shortener

/**
* See https://www.twilio.com/docs/sms/services.
Expand Down
55 changes: 24 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit ec8d4b1

Please sign in to comment.