Bagisto REST API is a medium to use the features of the core Bagisto system. By using the Bagisto REST API, you can integrate your application to serve the default content of Bagisto.
- Bagisto: v2.4.x
- PHP: ^8.3
Install the package via Composer:
composer require unopim/bagisto-rest-apiUse this when you want to keep the package source inside your project (for example, a fork you maintain).
-
Put the package source in
packages/Webkul/RestApi:git clone https://github.com/unopim/bagisto-rest-api.git packages/Webkul/RestApi rm -rf packages/Webkul/RestApi/.git
-
Register the namespace in the root
composer.jsonunderautoload.psr-4:"Webkul\\RestApi\\": "packages/Webkul/RestApi/src"
-
Register the service provider in
bootstrap/providers.php:Webkul\RestApi\Providers\RestApiServiceProvider::class,
-
Install the L5-Swagger dependency and refresh the autoloader:
composer require darkaonline/l5-swagger:^8.5 composer dump-autoload
Add your application's domain to the .env file so Sanctum can authenticate stateful requests. Use the host only (optionally host:port) — do not include the scheme or path:
SANCTUM_STATEFUL_DOMAINS=localhostPublish the L5-Swagger configuration and generate the API documentation:
php artisan bagisto-rest-api:installManual install only: because the package lives in
packages/Webkul/RestApi(notvendor/), open the publishedconfig/l5-swagger.phpand change the annotation paths frombase_path('vendor/unopim/bagisto-rest-api/src/Docs/...')tobase_path('packages/Webkul/RestApi/src/Docs/...'), then regenerate the docs:php artisan l5-swagger:generate --all.
Clear the caches:
php artisan optimize:clearOpen the following URLs in your browser (replace the host with your application's URL):
- Admin:
http://localhost/api/admin/documentation - Shop:
http://localhost/api/shop/documentation
The Bulk Product API processes products asynchronously through the queue. Set the queue connection in your .env:
QUEUE_CONNECTION=databaseThen run a queue worker so the dispatched bulk jobs are processed:
php artisan queue:workSee the L5-Swagger documentation for more details on configuring the API documentation.