unopim / bagisto-rest-api
Requires
- darkaonline/l5-swagger: ^8.5
Requires (Dev)
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
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.
1. Requirements
- Bagisto: v2.4.x
- PHP: ^8.3
2. Installation
Option A — Composer (recommended)
Install the package via Composer:
composer require unopim/bagisto-rest-api
Option B — Manual (place the package in packages/Webkul)
Use 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
Configure (both options)
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=localhost
Publish the L5-Swagger configuration and generate the API documentation:
php artisan bagisto-rest-api:install
Manual 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:clear
3. API Documentation
Open 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
4. Bulk Product API (Queues)
The Bulk Product API processes products asynchronously through the queue. Set the queue connection in your .env:
QUEUE_CONNECTION=database
Then run a queue worker so the dispatched bulk jobs are processed:
php artisan queue:work
See the L5-Swagger documentation for more details on configuring the API documentation.