community-sdks / mxroute-laravel
Laravel wrapper for the community-sdks/mxroute-php SDK
Requires
- php: ^8.2
- community-sdks/mxroute-php: ^1.0
- illuminate/contracts: ^10.0 || ^11.0 || ^12.0 || ^13.0
- illuminate/support: ^10.0 || ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^8.0 || ^9.0 || ^10.0 || ^11.0
- phpunit/phpunit: ^10.5 || ^11.0 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel integration for the strictly typed community-sdks/mxroute-php SDK.
Installation
composer require community-sdks/mxroute-laravel
The service provider and facade are discovered automatically. Publish the configuration if you want to customize it:
php artisan vendor:publish --tag=mxroute-config
Add your MXroute credentials to .env:
MXROUTE_API_KEY=your-api-key MXROUTE_SERVER=your-server.mxrouting.net MXROUTE_USERNAME=your-username
These optional settings are also available:
MXROUTE_BASE_URL=https://api.mxroute.com MXROUTE_TIMEOUT=30 MXROUTE_USER_AGENT=my-application/1.0
Usage
Inject the upstream client into a controller, job, command, or service:
use CommunitySDKs\MXRoute\DTOs\Requests\EmailAccounts\CreateEmailAccountRequest; use CommunitySDKs\MXRoute\MXRouteClient; final class CreateMailbox { public function __construct(private readonly MXRouteClient $mxroute) {} public function handle(): void { $this->mxroute->emailAccounts()->createEmailAccount( 'example.com', new CreateEmailAccountRequest( username: 'hello', password: 'SecurePassword1', quota: 1024, ), ); } }
Or use the facade:
use CommunitySDKs\MXRouteLaravel\Facades\MXRoute; $domains = MXRoute::domains()->listDomains();
All upstream services and DTOs remain available without an extra abstraction layer. See the upstream SDK documentation for its complete API.
Testing applications that use this package
Replace the client in Laravel's container with a test instance or an SDK client
built with a custom TransportInterface:
$fake = new \CommunitySDKs\MXRoute\MXRouteClient($fakeTransport); $this->app->instance(\CommunitySDKs\MXRoute\MXRouteClient::class, $fake);
License
The MIT License (MIT).