Install the Bundle
composer require artseld/openinviter-bundle
(Note: The original README uses a legacy Git-based install; Composer is preferred for modern Laravel/Symfony integration.)
Configure Credentials
Add your OpenInviter credentials to config/services.php (Laravel) or config/packages/artseld_openinviter.yaml (Symfony):
artseld_openinviter:
username: "YOUR_OPENINVITER_USERNAME"
private_key: "YOUR_API_KEY"
plugins_cache_time: 1800 # Cache plugins for 30 minutes
Set Up Routes
Add the bundle’s routes to routes/web.php (Laravel) or config/routes.yaml (Symfony):
// Laravel (routes/web.php)
Route::prefix('open-inviter')->group(function () {
require __DIR__.'/../vendor/artseld/openinviter-bundle/src/Resources/config/routing.php';
});
First Use Case: Display Available Providers Create a controller to fetch and render available invitation providers:
use Artseld\OpeninviterBundle\Service\OpenInviterService;
class InviteController extends Controller {
public function index(OpenInviterService $openInviter) {
$providers = $openInviter->getProviders();
return view('invite.providers', compact('providers'));
}
}
Fetch Providers Use the service to list supported providers (e.g., Gmail, LinkedIn, Facebook):
$providers = $openInviter->getProviders();
Authenticate User Redirect users to OpenInviter’s OAuth flow:
$authUrl = $openInviter->getAuthUrl('gmail', ['redirect_uri' => route('invite.callback')]);
return redirect($authUrl);
Handle Callback Process the OAuth callback to fetch contacts:
public function callback(OpenInviterService $openInviter) {
$contacts = $openInviter->getContacts('gmail', $this->request->query->all());
// Store contacts in DB or process further
}
Send Invitations Use the service to send bulk invites:
$results = $openInviter->sendInvites([
'to' => ['email1@example.com', 'email2@example.com'],
'message' => 'Join our platform!'
]);
$this->app->bind('artseld.openinviter', function ($app) {
return new \Artseld\OpeninviterBundle\Service\OpenInviterService(
$app['config']['artseld_openinviter']
);
});
plugins_cache_file to avoid file-system dependencies:
artseld_openinviter:
plugins_cache_file: "cache:oi_plugins" # Use Laravel's cache driver
dispatch(new SyncContactsJob($provider, $credentials));
Deprecated Symfony Version The bundle targets Symfony 2.1–2.3. For Laravel, use a wrapper or fork (e.g., laravel-openinviter). Workaround: Manually adapt the service class to Laravel’s DI container.
Missing Laravel Configuration
The bundle expects Symfony’s config.yml. For Laravel, map YAML config to config/services.php:
'openinviter' => [
'username' => env('OPENINVITER_USERNAME'),
'private_key' => env('OPENINVITER_API_KEY'),
'plugins_cache_time' => 1800,
],
Plugin Cache Issues
The default plugins_cache_file uses filesystem paths. For Laravel, override the cache handler:
$openInviter->setCacheHandler(new LaravelCacheHandler(storage_path('framework/cache')));
Transport Layer
The bundle defaults to wget. For Laravel, set transport: "curl" in config to avoid dependency conflicts.
local_debug: "on_error" in config to log errors to storage/logs/laravel.log.storage/logs/ for OAuth callback errors.Custom Providers Extend the service to support non-OpenInviter providers:
class CustomProvider extends \OpenInviter\Provider {
public function getContacts() { /* ... */ }
}
Register it via:
$openInviter->addProvider('custom', new CustomProvider());
Webhook Handling For real-time contact updates, implement a Laravel route to handle OpenInviter webhooks:
Route::post('openinviter/webhook', [InviteController::class, 'handleWebhook']);
Rate Limiting
Add Laravel’s throttle middleware to API routes to comply with OpenInviter’s rate limits:
Route::middleware(['throttle:60,1'])->group(function () {
// OpenInviter API routes
});
How can I help you explore Laravel packages today?