Download the PHP package eugenefvdm/api-framework without Composer
On this page you can find all versions of the php package eugenefvdm/api-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eugenefvdm/api-framework
More information about eugenefvdm/api-framework
Files in eugenefvdm/api-framework
Package api-framework
Short Description APIs for various services with Laravel Facade access and lots of automated tests.
License MIT
Homepage https://github.com/eugenefvdm/api
Informations about the package api-framework
API Framework
Another day, another API.
A set of Laravel API service providers.
- BulkSMS
- Discord
- DNS
- Fail2ban
- Hello Peter
- Slack
- Tail
- Telegram
- WHM/cPanel
- WHMCS
- X (Twitter)
- ZADomains
Installation
Publish the configuration file
Contents of config/api.php
Usage
Precede access by the facade namespace, e.g.
BulkSMS Unicode and custom wording
BulkSMS defaults to 7-bit messages. To make the Laravel facade send Unicode content like emoji, configure the encoding:
Then keep using the facade as usual:
For one-off Unicode sends, use the convenience method or a temporary encoding:
Supported encodings are 7bit, 16bit, and auto. The auto option sends GSM-safe text as 7-bit and switches to 16-bit when Unicode is needed.
For generic message length handling, use SmsText:
The BulkSMS client stays generic: it sends the message you give it and handles the transport encoding. If an app needs specific SMS wording, prepare that message first and then pass it to the generic sender.
For example, Hellopeter review notifications can use the included formatter before sending:
Here is a list of all the API calls:
WHM/cPanel .env keys are only required when you call those APIs. Guard with Whm::isConfigured() / Cpanel::isConfigured() if they may be missing.
WHM API token privileges
Create a token in WHM → Development → Manage API Tokens. Whitelist the caller IP, and grant only the privileges below - do not enable Everything (all).
| What you want to do | Code / call | Privilege (red label in WHM) | Category in WHM |
|---|---|---|---|
| List hosting packages / plans | Whm::listPackages() → listpkgs |
list-pkgs |
Packages → List Packages |
| Look up which account owns a domain | Whm::domainOwner() → getdomainowner |
list-accts |
Account Information → List Accounts |
| Park (alias) a domain | Whm::parkDomain() → create_parked_domain_for_user |
park-dns |
DNS → Park DNS Zones |
| List parked domains for an account | Whm::listParkedDomains() → cPanel API2 Park::listparkeddomains via /json-api/cpanel |
cpanel-api |
Initial Privileges → Perform cPanel API and UAPI functions through the WHM API |
| Find one parked domain (owner lookup + list) | Whm::findParkedDomain() |
list-accts and cpanel-api |
As above |
Minimum set for parking + package listing: park-dns, list-accts, cpanel-api, list-pkgs.
Notes:
listParkedDomains/ email helpers go through the WHM cPanel proxy, so they needcpanel-api, not a separate “list parked domains” ACL.listPackages(want: 'all')returns root and reseller packages; package create/edit/delete privileges are not required.
Testing
Design philosophy
APIs can be hard. Reading documentation is a drag. And what if you only want to use a few calls? Do you really have to learn everything? This framework gives you the power of many APIs in one package. It's minimalist and uses Laravel's facades for easy access.
Each call is tested using stubs which doubles as a handy reference.
Contribution Guidelines
- Fork the repository
- Create a new branch for your changes (
git checkout -b feature/amazing-api) - Make your changes
- Run the tests (
./vendor/bin/pest) - Run Larastan (
./vendor/bin/phpstan analyse) - Submit a pull request
When adding a new API, add both ApiServiceProvider, ApiManager and a Facade.
Code Style & Standards
- Pint is installed, so simply run
vendor/bin/pintto make your code clean - For new APIs and API calls:
- Add feature tests with stubs (see existing examples)
- Ensure stubs are redacted of sensitive information
- Follow the existing naming conventions:
- Capitalize only the first letter of API's name, e.g.,
Bulksms,Zadomains - For compound names, also don't capatalize, e.g.,
Hellopeter - Getters should not be prepended by "get", e.g. use
message()instead ofgetMessage() - Setters should be prepended by "set", e.g.
setServer() - All API responses should follow this format:
Need Help?
If you have an idea for a new API or API call but don't have time to implement it, feel free to open a new issue to see if we can do an implementation.
All versions of api-framework with dependencies
illuminate/database Version *
illuminate/support Version ^8.12|^9.0|^10.0|^11.0|^12.0|^13.0
spatie/ssh Version ^1.13