Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Crowdentials Api Wrapper Laravel Package

crowdvalley/crowdentials-api-wrapper

PHP wrapper for the CrowdValley (Crowdentials) API, simplifying authentication and common requests so Laravel/PHP apps can integrate CrowdValley services with a cleaner, reusable client.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require crowdvalley/crowdentials-api-wrapper
    

    Add the service provider to config/app.php under providers:

    CrowdValley\CrowdentialsApiWrapper\CrowdentialsServiceProvider::class,
    
  2. Publish Config

    php artisan vendor:publish --provider="CrowdValley\CrowdentialsApiWrapper\CrowdentialsServiceProvider"
    

    Configure .env with your Crowdentials API credentials:

    CROWDENTIALS_API_KEY=your_api_key_here
    CROWDENTIALS_API_SECRET=your_api_secret_here
    CROWDENTIALS_API_URL=https://api.crowdentials.com
    
  3. First Use Case: Fetching a User’s Credentials

    use CrowdValley\CrowdentialsApiWrapper\Facades\Crowdentials;
    
    $userCredentials = Crowdentials::user()->get('user_id_here');
    

Implementation Patterns

Core Workflows

  1. User Management

    • Fetch User Data:
      $user = Crowdentials::user()->find('user_id');
      
    • Create/Update User:
      $user = Crowdentials::user()->createOrUpdate([
          'email' => '[email protected]',
          'password' => 'secure_password123',
          'metadata' => ['role' => 'admin']
      ]);
      
    • Delete User:
      Crowdentials::user()->delete('user_id');
      
  2. Authentication

    • Login:
      $token = Crowdentials::auth()->login('[email protected]', 'password');
      
    • Logout:
      Crowdentials::auth()->logout($token);
      
  3. Credential Rotation

    • Rotate Password:
      Crowdentials::user()->rotatePassword('user_id', 'new_secure_password');
      
  4. Bulk Operations

    • Bulk Fetch:
      $users = Crowdentials::user()->all(['id' => ['user1', 'user2']]);
      

Integration Tips

  • Laravel Auth Guard: Extend Laravel’s Authenticatable to use Crowdentials tokens:
    public function getAuthIdentifier()
    {
        return $this->crowdentials_token;
    }
    
  • Middleware: Protect routes with Crowdentials token validation:
    Crowdentials::auth()->validateToken($request->bearerToken());
    
  • Event Listeners: Subscribe to Crowdentials webhooks for real-time updates:
    Crowdentials::events()->listen('user.created', function ($user) {
        // Handle new user
    });
    

Gotchas and Tips

Pitfalls

  1. Rate Limiting

    • Crowdentials API enforces rate limits. Cache responses aggressively:
      $user = Cache::remember("crowdentials_user_{$userId}", now()->addMinutes(5), function () use ($userId) {
          return Crowdentials::user()->find($userId);
      });
      
    • Monitor 429 Too Many Requests responses and implement exponential backoff.
  2. Token Expiry

    • Tokens expire after 24 hours. Refresh silently in middleware:
      if (Crowdentials::auth()->isTokenExpired($token)) {
          $token = Crowdentials::auth()->refreshToken($token);
      }
      
  3. Sensitive Data

    • Never log raw API responses containing passwords or tokens. Use:
      \Log::debug('Crowdentials response', ['data' => $response->sanitize()]);
      

Debugging

  • Enable Debug Mode:

    CROWDENTIALS_DEBUG=true
    

    Logs API requests/responses to storage/logs/crowdentials.log.

  • Mock API Calls (for testing):

    $this->partialMock(Crowdentials::class, function ($mock) {
        $mock->shouldReceive('get')->andReturn(['id' => 'test_user']);
    });
    

Extension Points

  1. Custom Endpoints Override the base client to add endpoints:

    Crowdentials::extend('custom', function ($app) {
        return new CustomCrowdentialsClient($app['http.client']);
    });
    
  2. Response Transformers Modify responses before they’re returned:

    Crowdentials::user()->transformer(function ($response) {
        return collect($response)->merge(['formatted_at' => now()->toDateTimeString()]);
    });
    
  3. Webhook Handling Validate signatures in your webhook endpoint:

    $payload = Crowdentials::events()->validateWebhook($request->getContent(), $request->header('X-Signature'));
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels