Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major overhaul for a possible 4.x release, twilio/sdk 8.x #148

Merged
merged 30 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
37a859f
Add enabled config
ajcastro Jun 8, 2021
220c067
Add test and fixes
ajcastro Jun 8, 2021
0b4a332
Fix
ajcastro Jun 8, 2021
5daeb27
Fix style
ajcastro Jun 8, 2021
a50563b
Enable overriding the Twilio message source
misenhower Jun 27, 2023
0cd8604
Merge pull request #1 from onlime/121-enabled-config
onlime Nov 17, 2024
88f2572
Merge remote-tracking branch 'origin/v4' into 142-totwilio-override
onlime Nov 17, 2024
ddf2ed5
Merge pull request #2 from onlime/142-totwilio-override
onlime Nov 17, 2024
4abe9b0
Drop Laravel 7-10
onlime Nov 17, 2024
8759f4f
Added Pint and fixed PHP syntax
onlime Nov 17, 2024
2164988
Use modern syntax: Constructor property promotion, improved types
onlime Nov 17, 2024
b68f87c
Bump twilio/sdk to 8.3
onlime Nov 17, 2024
0df7062
Fixing Twilio and TwilioChannel tests
onlime Nov 18, 2024
ea628cf
Fix more tests
onlime Nov 18, 2024
a1ac763
Migrated legacy phpunit.xml.dist configuration schema
onlime Nov 18, 2024
0871af1
Added PhpUnit 10.5 to CHANGELOG
onlime Nov 18, 2024
983b372
Updated Build Status badge in README, removed broken StyleCI badge/link
onlime Nov 18, 2024
a18719e
rebranding to onlime/laravel-twilio
onlime Nov 20, 2024
b74ac9c
Added test for `TwilioConfig` class
pascalbaljet Nov 21, 2024
5cef1de
Updated and improved `TwilioProviderTest`
pascalbaljet Nov 21, 2024
96e7113
Additional tests to achieve 100% code coverage
pascalbaljet Nov 21, 2024
fd9b344
Only use Laravel Pint styling
pascalbaljet Nov 21, 2024
3f632bb
Remove scrutinizer badges
pascalbaljet Nov 21, 2024
cf2e7fa
Added PHP Linting (Pint) to CI workflow
onlime Nov 21, 2024
1b0490a
Merge remote-tracking branch 'origin/4.x' into onlime-rebrand
onlime Nov 21, 2024
9a464ae
Added Pascal to contributors
onlime Nov 21, 2024
745732f
Merge pull request #3 from onlime/onlime-rebrand
onlime Nov 21, 2024
3e6f016
more onlime/laravel-twilio rebranding fixes
onlime Nov 21, 2024
310888d
rounded badges
onlime Nov 21, 2024
f90ab62
Revert the rebranding froma 18719e & 3e6f016 back to laravel-notifica…
onlime Nov 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 gregoriohc@gmail.com instead of using the issue tracker.
If you discover any security related issues, please email pipo@onlime.ch 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": "pipo@onlime.ch",
"homepage": "https://github.com/onlime",
"role": "Developer"
},
{
"name": "Gregorio Hernández Caso",
"email": "gregoriohc@gmail.com",
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