1. Go to this page and download the library: Download ratespecial/logto-laravel 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/ */
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Ratespecial\Logto\Contracts\OAuthScopable;
use Ratespecial\Logto\HasOAuthScopes;
class User extends Authenticatable implements OAuthScopable
{
use HasOAuthScopes;
protected $fillable = ['name', 'email', 'logto_sub'];
}
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\OrderController;
// Authenticate only
Route::get('/api/me', fn () => auth('logto')->user())
->middleware('auth:logto');
// Authenticate +
use Illuminate\Support\Facades\Event;
use Ratespecial\Logto\Events\UserProvisionedEvent;
Event::listen(function (UserProvisionedEvent $event) {
// $event->user is the freshly-created Authenticatable
// Send a welcome email, kick off onboarding, etc.
});
use Laravel\Mcp\Facades\Mcp;
use App\Mcp\Servers\MyServer;
Mcp::web('/mcp', MyServer::class)
->middleware(['auth:logto', 'can:mcp:use']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.