PHP code example of mwstake / mediawiki-component-wellknown

1. Go to this page and download the library: Download mwstake/mediawiki-component-wellknown 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/ */

    

mwstake / mediawiki-component-wellknown example snippets


use MediaWiki\MediaWikiServices;

$registry = MediaWikiServices::getInstance()
    ->getService( 'MWStake.WellKnown.FileRegistry' );

$registry->register(
    'openid-configuration',
    static function () {
        return json_encode( [
            'issuer' => 'https://wiki.example.com',
            'jwks_uri' => 'https://wiki.example.com/.well-known/jwks.json',
            'response_types_supported' => [ 'id_token' ],
        ] );
    },
    'application/json'
);

// JSON discovery document
$registry->register( 'openid-configuration', static function () {
    return json_encode( [ 'issuer' => '...' ] );
}, 'application/json' );

// Plain text security contact
$registry->register( 'security.txt', static function () {
    return "Contact: [email protected]\nExpires: 2027-01-01T00:00:00.000Z\n";
}, 'text/plain' );

// PEM-encoded certificate
$registry->register( 'est/cacerts', static function () use ( $certPath ) {
    return file_get_contents( $certPath );
}, 'application/pkcs7-mime' );

GET {wiki_base_url}/rest.php/.well-known/{filename}