nikitanp / laravel-discourse
PHP Discourse Forum API for the Laravel Framework
1.0.3
2021-05-23 10:48 UTC
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^4
- vimeo/psalm: ^4.7
README
Version Compatibility
Laravel framework 6 and higher.
Getting Started
Before going through the rest of this documentation, please take some time to read the Discourse API Documentation. Not all of the API calls are documented, but it's a good place to start. Additional help with SSO: https://meta.discourse.org
Installation
composer require nikitanp/laravel-discourse
This package auto discovered by laravel!
You can optionally publish the config file with:
php artisan vendor:publish --provider="NikitaMikhno\LaravelDiscourse\DiscourseServiceProvider" --tag="config"
Configure Laravel Discourse API Library
Laravel Env
Set the API Token, Forum url and SSO Token in your .env:
DISCOURSE_URL=https://forum.url
DISCOURSE_SECRET={sso secret}
DISCOURSE_TOKEN={api token}
DISCOURSE_SSO_ENABLED=true/false
Discourse Env
Enable SSO Via UI: see: "{DISCOURSE_URL}/admin/site_settings/category/required?filter="
Via console:
cd /var/discourse ./launcher enter app rails c irb > SiteSetting.sso_secret = {config('discourse.secret')} irb > SiteSetting.sso_url = {config('discourse.route')} irb > SiteSetting.logout_redirect = {config('discourse.logout')} irb > SiteSetting.enable_sso = true irb > SiteSetting.enable_local_logins = false irb > exit exit
Credits
Forked from: matthew-jensen/laravel-discourse-client.
SSO Helper Methods: cviebrock/discourse-php.
SSO Controller Methods: spinen/laravel-discourse-sso.