Download the PHP package danyseifeddine/keychain without Composer

On this page you can find all versions of the php package danyseifeddine/keychain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package keychain

🔐 KeyChain - Laravel Social Authentication Package

The most powerful and flexible Laravel social authentication package with multi-guard support, automatic setup, and complete customization control.

KeyChain provides an elegant solution for implementing social login across multiple user types (Users, Restaurants, Admins, etc.) with automatic guard registration, dynamic user creation, polymorphic token storage, and infinitely customizable authentication flows.

Latest Version on Packagist Total Downloads License

🚀 Features

📋 Table of Contents

  1. Installation
  2. Basic Configuration
  3. Simple Usage
  4. Multi-Guard Setup
  5. Publishing Assets
  6. Controller Customization
  7. Magic Methods
  8. Token Management
  9. Helper Functions
  10. Commands
  11. Advanced Configuration
  12. Examples
  13. Troubleshooting

🚀 Installation

1. Install via Composer

2. Publish Configuration and Assets

3. Run Migrations

4. Add Social Provider Credentials

Add your OAuth credentials to .env:


⚙️ Basic Configuration

Update config/keychain.php to enable providers:


🎯 Simple Usage

Basic Social Login (Single Guard)

KeyChain automatically generates these routes:

In your Blade template:

User Model Setup

Add the HasSocialAccounts trait to your User model:

That's it! KeyChain will automatically:


🛡️ Multi-Guard Setup

1. Enable Multi-Guard in Config

2. Create Guard Models

3. Multi-Guard Routes

KeyChain automatically generates guard-specific routes:

4. Multi-Guard Login Template


📦 Publishing Assets

KeyChain provides several publishable assets for customization:

Available Publishing Tags

What Gets Published

Tag Files Published Purpose
keychain-config config/keychain.php Main configuration file
keychain-migrations database/migrations/xxx_create_key_chain_tokens_table.php Token storage migration
keychain-views resources/views/keychain/ Login and dashboard templates
keychain-controller app/Http/Controllers/Auth/SocialAuthController.php Customizable controller
keychain-env keychain.env Environment variables template

🎛️ Controller Customization

Publishing the Controller

This creates app/Http/Controllers/Auth/SocialAuthController.php which extends the base controller.

Magic Methods (Dynamic Guard Support)

KeyChain automatically looks for guard-specific methods:

Lifecycle Hooks

Override these methods for custom logic at different stages:

Complete Callback Override

For ultimate control, override the entire authentication flow:


🪄 Magic Methods

KeyChain's magic method system automatically handles guard-specific user creation and updates without requiring you to define every method.

How Magic Methods Work

  1. Method Pattern: create{Guard}User() and update{Guard}User()
  2. Automatic Detection: KeyChain detects the guard from the method name
  3. Dynamic Fallback: If method doesn't exist, uses dynamic creation from config
  4. Case Handling: Converts method names to proper guard names automatically

Examples

Guard Name Create Method Update Method
web createWebUser() updateWebUser()
restaurant createRestaurantUser() updateRestaurantUser()
admin createAdminUser() updateAdminUser()
merchant createMerchantUser() updateMerchantUser()
customer_support createCustomerSupportUser() updateCustomerSupportUser()

Dynamic Creation (When Methods Don't Exist)

If you don't define custom methods, KeyChain automatically creates users using the guard's model and configuration:

Enabling/Disabling Magic Methods

Magic Method Debugging

Enable debug mode to see magic method calls:

Check storage/logs/laravel.log for magic method calls:


🔐 Token Management

KeyChain provides comprehensive token management with polymorphic relationships, expiration control, and automatic cleanup.

Token Storage Schema

Tokens are stored in the key_chain_tokens table with polymorphic relationships:

Token Expiration Configuration

Setting Infinite Tokens (Never Expire)

When infinite is true, all tokens get expires_at = null and never expire.

Custom Token Expiration Logic

Override the token expiration logic in your controller:

Working with Tokens in Your Models

Using the HasSocialAccounts trait:

Token Model Methods

The KeyChainToken model provides useful methods:


🛠️ Helper Functions

KeyChain provides a comprehensive helper class with utility methods for social authentication management.

KeyChainHelper Class

All helper methods are available via the KeyChainHelper class:

Provider Management

Guard Management

URL Generation

User Social Account Management

Token Cleanup

Authentication Statistics

Using Helpers in Blade Templates

Custom Helper Usage in Controllers


🎯 Commands

KeyChain provides powerful Artisan commands for managing social authentication tokens and providers.

Available Commands

Provider Management

Token Management

Token Cleanup

Token Revocation

Statistics

Automated Token Cleanup

Set up automated token cleanup using Laravel's scheduler:

Command Options Summary

Command Options Description
keychain providers None List provider status
keychain tokens --provider, --user, --expired List and filter tokens
keychain cleanup --provider, --user, --force Clean expired tokens
keychain revoke --provider, --user, --force Revoke active tokens
keychain stats None Show statistics

⚙️ Advanced Configuration

Complete Configuration Reference

Environment Variables Reference

Adding Custom Providers

KeyChain supports any Laravel Socialite provider. To add a custom provider:

  1. Install the provider package:

  2. Add to services config:

  3. Add environment variables:

  4. Register the provider (if needed):

Custom Middleware

Add custom middleware to routes:

Performance Optimization

Security Best Practices


💡 Examples

Complete Multi-Restaurant Application

This example shows a complete setup for a multi-restaurant platform where restaurant owners can log in to manage their restaurants.

1. Configuration

2. Models

3. Custom Controller

4. Multi-Guard Login View

5. Restaurant Dashboard

6. Routes

This example demonstrates a complete multi-restaurant platform with:


🔧 Troubleshooting

Common Issues and Solutions

1. Routes Not Working

Problem: KeyChain routes return 404 errors

Solutions:

Check configuration:

2. Published Controller Not Being Used

Problem: Custom methods in published controller aren't called

Solution: The package automatically detects and uses the published controller. Verify:

3. Guard Detection Issues

Problem: Wrong guard is detected during authentication

Debug steps:

Common causes:

4. Social Provider Configuration

Problem: Provider redirects fail or show errors

Check credentials:

Verify OAuth app settings:

5. Database/Migration Issues

Problem: Token storage fails or migration errors

Solutions:

6. Token Expiration Issues

Problem: Tokens expire immediately or never expire

Check configuration:

7. Magic Methods Not Working

Problem: Dynamic methods like createRestaurantUser() not called

Verify configuration:

Debug magic methods:

8. Memory/Performance Issues

Problem: High memory usage or slow performance

Optimization steps:

Performance config:

Debug Checklist

When troubleshooting, work through this checklist:

  1. ✅ Environment Setup

    • [ ] Composer package installed
    • [ ] Configuration published
    • [ ] Migrations run
    • [ ] Environment variables set
  2. ✅ Configuration

    • [ ] Providers enabled in config/keychain.php
    • [ ] Services configured with credentials
    • [ ] Guards configured (if using multi-guard)
    • [ ] Routes enabled
  3. ✅ OAuth Provider Setup

    • [ ] OAuth app created in provider console
    • [ ] Redirect URIs match exactly
    • [ ] Client ID and secret correct
    • [ ] OAuth app enabled/published
  4. ✅ Laravel Setup

    • [ ] Models have HasSocialAccounts trait
    • [ ] Guards registered in auth.php (for multi-guard)
    • [ ] Routes not conflicting
    • [ ] Middleware working correctly
  5. ✅ Debugging
    • [ ] Enable debug mode temporarily
    • [ ] Check Laravel logs
    • [ ] Verify route registration
    • [ ] Test with simple single-guard setup first

Getting Help

If you're still experiencing issues:

  1. Check the logs: Always check storage/logs/laravel.log with debug mode enabled
  2. Minimal reproduction: Try with a fresh Laravel install and minimal config
  3. Community support: Open an issue on GitHub with:
    • Laravel version
    • KeyChain version
    • Complete error message
    • Relevant configuration
    • Steps to reproduce

📄 Requirements

📜 License

KeyChain is open-sourced software licensed under the MIT license.

🤝 Contributing

Contributions are welcome! Please see our contributing guidelines for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📞 Support

🚀 What's Next?

KeyChain is actively maintained and continuously improved. Upcoming features:


Made with ❤️ by Dany Seifeddine

⭐ If KeyChain helps you, please star the repository!


All versions of keychain with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1|^8.2|^8.3|^8.4
laravel/framework Version ^10.0|^11.0|^12.0
laravel/socialite Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package danyseifeddine/keychain contains the following files

Loading the files please wait ....