This package offers an authentication guard to seamlessly integrate Clerk authentication into your Laravel project.
- Use Composer to install the package:
composer require ronasit/laravel-clerk
- Publish the package configuration:
php artisan vendor:publish --provider=RonasIT\\Clerk\\Providers\\ClerkServiceProvider
- Add a new
clerk
guard within theguards
array in yourconfig/auth.php
file:
return [
'defaults' => [
'guard' => 'clerk',
'passwords' => 'users',
],
'guards' => [
'clerk' => [
'driver' => 'clerk_session',
'provider' => 'users',
],
// Other guards...
],
- Populate the necessary configuration options in
config/clerk.php
.
By default, your app returns the User class with just the external_id property, which holds the user's ID in Clerk.
To customize this behavior, you'll need to create your own UserRepository that implements the UserRepositoryContract. Then, rebind it in one of the service providers:
use RonasIT\Clerk\Contracts\ClerkUserRepositoryContract;
use App\Support\Clerk\MyAwesomeUserRepository;
class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->bind(ClerkUserRepositoryContract::class, MyAwesomeUserRepository::class);
}
}