PHP code example of matthew-jensen / laravel-discourse

1. Go to this page and download the library: Download matthew-jensen/laravel-discourse library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

matthew-jensen / laravel-discourse example snippets


    /*
    * $APP_PATH/config/app.php
    */
    'providers' => [
        MatthewJensen\LaravelDiscourse\DiscourseServiceProvider::class
    ],


return [

    // API token. 
    'token' => env('DISCOURSE_TOKEN')

    // Middleware for the SSO login route to use
    'middleware' => ['web', 'auth'],

    // The route's URI that acts as the entry point for Discourse to start the SSO process.
    // Used by Discourse to route incoming logins.
    'route' => 'discourse/sso',
    'logout' => 'discourse/sso/logout',
    
    // Secret string used to encrypt/decrypt SSO information,
    // be sure that it is 10 chars or longer
    'secret' => env('DISCOURSE_SECRET'),
    
    // Disable Discourse from sending welcome message
    'suppress_welcome_message' => 'true',
    
    // Where the Discourse forum lives
    'url' => env('DISCOURSE_URL'),
    
    // User-specific items
    // NOTE: The 'email' & 'external_id' are the only 2 ified)
        'email' => 'email',
        
        // Unique string for the user that will never change
        'external_id' => 'id',
        
        // Boolean for making user a Discourse moderator. Leave null to ignore 
        'moderator' => 'discourse_moderator',
        
        // Full name on Discourse if the user is new or 
        // if SiteSetting.sso_overrides_name is set
        'name' => 'name',

        // Discourse Groups to make sure that the user is *NOT* part of in a comma-separated string.
        // NOTE: Groups cannot have spaces in their names & must already exist in Discourse
        // There is not a way to specify the exact list of groups that a user is in, so
        // you may want to send the inverse of the 'add_groups'
        'remove_groups' => null,
        
        // If the email has not been verified, set this to true
        '
bash
php artisan vendor:publish --provider="MatthewJensen\LaravelDiscourse\DiscourseServiceProvider" --tag="config"