Installation:
composer require splash/php-bundle
Add the bundle to config/bundles.php in Symfony:
return [
// ...
Splash\Bundle\CoreBundle\SplashCoreBundle::class => ['all' => true],
];
First Use Case:
Splash\CoreBundle\Security\Authenticator\OAuth2Authenticator in your security.yaml:
firewalls:
main:
oauth2:
provider: splash_oauth_provider
Configuration:
php bin/console splash:install
config/packages/splash_core.yaml with your OAuth2 credentials (client ID, secret, etc.).Quick Test:
/connect/splash endpoint.OAuth2 Integration:
Splash\CoreBundle\Security\OAuth2\Provider\AbstractProvider for custom providers.Splash\CoreBundle\Security\User\UserMapperInterface to sync Splash users with your Symfony users.
class SplashUserMapper implements UserMapperInterface {
public function mapUser(array $data): UserInterface {
return new User($data['email'], $data['password']);
}
}
API Client:
Splash\CoreBundle\Client\SplashClient for API calls:
$client = $this->container->get('splash.client');
$response = $client->get('/api/v1/users');
Event Listeners:
splash.user.created) via Symfony’s event dispatcher:
$dispatcher->addListener('splash.user.created', function (UserEvent $event) {
// Handle user creation logic
});
Command-Line Tools:
php bin/console splash:sync:users
Splash\CoreBundle\Form\Type\UserType.splash Twig extension:
{{ splash.user.displayName }}
Splash\CoreBundle\Doctrine\SplashEntity.Deprecated Methods:
EventDispatcherInterface changes).config/services.yaml:
Splash\CoreBundle\:
resource: '../vendor/splash/php-bundle/src/'
exclude: '../vendor/splash/php-bundle/src/{Entity,DependencyInjection}'
OAuth2 Flow:
redirect_uri in Splash dashboard matches your Symfony login_path (e.g., /connect/splash/check).splash_core.yaml:
splash_core:
debug: true
User Sync:
UserMapper may not handle all Splash fields. Extend it to map custom attributes:
public function mapUser(array $data): UserInterface {
$user = new User();
$user->setEmail($data['email'] ?? '');
$user->setCustomField($data['custom_field'] ?? null); // Add missing fields
return $user;
}
Caching:
php bin/console cache:clear
Custom Providers:
AbstractProvider to support non-OAuth2 auth (e.g., API keys):
class ApiKeyProvider extends AbstractProvider {
public function getCredentials(): array {
return ['api_key' => $this->request->headers->get('X-API-KEY')];
}
}
Webhooks:
Splash\CoreBundle\Event\WebhookListenerInterface:
class CustomWebhookListener implements WebhookListenerInterface {
public function onWebhookReceived(WebhookEvent $event) {
// Handle webhook payload
}
}
Testing:
SplashClient in tests:
$client = $this->createMock(SplashClient::class);
$client->method('get')->willReturn(['data' => 'test']);
$this->container->set('splash.client', $client);
%env% in splash_core.yaml:
splash_core:
client_id: '%env(SPLASH_CLIENT_ID)%'
client_secret: '%env(SPLASH_CLIENT_SECRET)%'
use GuzzleHttp\Exception\RequestException;
try {
$response = $client->get('/api/v1/users');
} catch (RequestException $e) {
if ($e->getCode() === 429) {
sleep(2); // Retry after delay
}
}
How can I help you explore Laravel packages today?