bullsoft / laravel-loader
Load Laravel-Application in your codebase.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/bullsoft/laravel-loader
This package is auto-updated.
Last update: 2025-09-21 00:36:15 UTC
README
奇怪的需求产生奇怪的方案,本方案就是。。。
Load Laravel-Application in your codebase.
$conf = [ 'basePath' => '/path/to/your/laravel-app', 'url' => 'http://redirect/to/when/login/successfully', ]; $laravel = \BullSoft\Loader\Laravel::bootstrap($conf['basePath']); if(!$laravel->checkUserLogin()) { $info = ['username' => 'roy', 'password' => 'iloveroy']; $laravel->login($info, $conf['url']); // use null for second param when you do not want to redirect } $request = $laravel->newApiRequest('/api/v1/user/index', 'GET'); $response = $laravel->sendRequest($request); $content = $response->getContent(); $laravel->finish($request, $response); echo $content;