strangefate / socialrouter
This package will add and handle routes for use with the Laravel Socialite package, along with some default views and sass files.
Requires
- php: ^7.2.5|^8.0
- laravel/framework: ^8.0|^9.0
- laravel/socialite: ^5.0
This package is auto-updated.
Last update: 2025-04-21 01:06:26 UTC
README
This package will install Laravel Socialite and add routes to your project to handle loging in with a Social network platform. You can easily configure what networks are available through a config file. This package includes simple views for use in your project, along with an sass file with social platform color brands for your project.
This package has checks to insure that only the configured networks are accessible. Users can upgrade their account to a social platform for easier access. Users can not register multiple networks with the same email address to prevent account spoofing.
Package Installation:
Require package
composer require strangefate/socialrouter
Run migration to add platform variables to the user database
php artisan migrate
Modify the User model so the new fields are fillable
//old
protected $fillable = [
'name', 'email', 'password',
];
//new - option 1
protected $fillable = [
'name', 'email', 'password','platform','platform_id','platform_image'
];
//new - option 2
protected $guarded = ['email_verified_at', 'remember_token'];
You can test if the package is properly installed by checking the route list in your project. You should see two new routes for /auth/{provider} and an /auth/logout route
php artisan route:list
Configuration
Several default platforms are available in the social router package, please see the Laravel Socialite documentation and the Social Network's platform for details on what supported and how to configure them. Publish the config file to configure the platforms you want your application to support. The config file also contains snippets for adding variables to your services config and env file.
php artisan vendor:publish --provider=StrangeFate\SocialRouter\SocialRouterServiceProvider --tag=config
Remove the providers you don't want from the socialrouter.php file configure the access tokens in your app's config\services.php . Only providers you list in the config file will be supported, anything not in the config file will be dealt a 404 error.
Assets
You can publish the sass and view files to customize the templates for your site.
php artisan vendor:publish --provider=StrangeFate\SocialRouter\SocialRouterServiceProvider --tag=assets
The sass file contains a standard collection of social platforms brand colors for your project. Add this document to your sass project and it will create classes for anchor tags in the platforms color or buttons with that platform as a background.
resources\sass\socialcolors.scss
The socialcolors.scss is a sass file that has brand colors for all your projects. Add this to your sass compilation to have them added to your style sheet.
@import "socialcolors";
<a class="twitter" href="#">Twitter</a>
<button class="button facebook">Facebook</button>
View templates
The social router comes with pre-made templates for you to include in your project. Templates are based off of Zurb Foundation Sites Libraries. Customize these to fit your platform.
@include('socialrouter::menu-list-default')
@include('socialrouter::inline-list')
@include('socialrouter::menu-list-vertical')
@include('socialrouter::button-list')