https://github.com/tattersoftware/codeigniter4-pushover
Pushover integration for CodeIgniter 4
https://github.com/tattersoftware/codeigniter4-pushover
Last synced: 9 months ago
JSON representation
Pushover integration for CodeIgniter 4
- Host: GitHub
- URL: https://github.com/tattersoftware/codeigniter4-pushover
- Owner: tattersoftware
- License: mit
- Created: 2020-06-25T00:10:38.000Z (almost 6 years ago)
- Default Branch: develop
- Last Pushed: 2023-02-03T10:03:11.000Z (over 3 years ago)
- Last Synced: 2025-08-23T06:07:28.240Z (10 months ago)
- Language: PHP
- Size: 56.6 KB
- Stars: 5
- Watchers: 2
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tatter\Pushover
Pushover integration for CodeIgniter 4
[](https://github.com/tattersoftware/codeigniter4-pushover/actions?query=workflow%3A%22PHP+Unit+Tests)
## Quick Start
1. Install with Composer: `> composer require tatter/pushover`
2. Add credentials to **.env** or **Config/Pushover.php**
3. Send an alert: `service('pushover')->message(['message' => 'Hello world'])->send();`
## Description
**Tatter\Pushover** adds an easy-to-use class for [Pushover](https://pushover.net)
to your CodeIgniter 4 project. Send push notifications and access other API endpoints with
the integrated Service and support entities.
## Configuration (optional)
The library's default behavior can be altered by extending its config file. Copy
**examples/Pushover.php** to **app/Config/** and follow the instructions
in the comments. If no config file is found in **app/Config** then the library will use its own.
In order to interface with Pushover you will need to specify your user secret and app token.
As these are sensitive items it is highly recommended you supply them in your **.env** file
instead of directly to repository code, e.g. (fake values):
```
pushover.user = e9e1495ec75826de5983cd1abc8031
pushover.token = KzGDORePKggMaC0QOYAMyEEuzJnyUi
```
## Usage
Load the service with CodeIgniter's service helper:
$pushover = service('pushover');
Then craft your message and send it off to Pushover:
```
use Tatter\Pushover\Entities\Message;
$message = new Message([
'title' => 'My Message',
'message' => 'This is my first CodeIgniter push notification!',
'priority' => 1,
]);
$pushover->sendMessage($message);
```
You may also use class convenience methods to draft Messages with pre-defined default
properties (see **examples/Pushover.php** for configuration):
```
$message = $pushover->message(['message' => 'Hellow world']);
$message->send();
```
## Troubleshooting
Follow Pushover's [API specifications](https://pushover.net/api#messages) to make sure
your messages are valid and you usage complies with their policies. Use the class method
`Pushover::getErrors()` to access any error messages should something go wrong:
```
try
{
$pushover->message(['title' => 'New Boots', 'attachment' => 'boots.jpg'])->send();
}
catch (\Tatter\Pushover\Exceptions\PushoverException $e)
{
d($pushover->getErrors());
}
...
array (2) [
0 => string (23) "message cannot be blank"
1 => string (37) "The API returned a failing status: 0."
]
```
## Development
Currently this module only supports the `messages.json` endpoint (including attachments),
but more endpoints will be added in the future. If you have a specific request please open
an issue (or PR!) for a new feature request.