Setup & Configuration
Get the Bagisto API up and running in just a few minutes. Choose the installation method that works best for your setup.
Prerequisites
Before installing, ensure you have:
- Bagisto v2.0 or higher (Bagisto Installation Guide)
- Composer 2.0+
Installation Methods
Method 1: Quick Start (Composer Installation – Recommended)
The fastest way to get started:
# 1. Install the Bagisto API package
composer require bagisto/bagisto-api
# 2. Run the installer
php artisan bagisto-api-platform:installYour APIs are now ready! Access them at:
- API Documentation:
https://your-domain.com/api
(e.g., https://api-demo.bagisto.com/api)
Method 2: Manual Installation
Use this method if you need more control over the setup.
Step 1: Download and Extract
- Download the BagistoApi package from GitHub
- Extract it to:
packages/Webkul/BagistoApi/
Step 2: Register Service Provider
Edit bootstrap/providers.php:
<?php
return [
// ...existing providers...
Webkul\BagistoApi\Providers\BagistoApiServiceProvider::class,
// ...rest of providers...
];Step 3: Update Autoloading
Edit composer.json and update the autoload section:
{
"autoload": {
"psr-4": {
"Webkul\\BagistoApi\\": "packages/Webkul/BagistoApi/src"
}
}
}Step 4: Install Dependencies
# Install required packages
composer require api-platform/laravel:v4.1.25
composer require api-platform/graphql:v4.2.3Step 5: Run the installation
composer dump-autoload
php artisan bagisto-api-platform:installStep 9: Environment Setup (Update in the .env)
STOREFRONT_DEFAULT_RATE_LIMIT=100
STOREFRONT_CACHE_TTL=60
STOREFRONT_KEY_PREFIX=storefront_key_
STOREFRONT_PLAYGROUND_KEY=pk_storefront_vxLIYv5PIp7jkujPNGLFQoDvIdsh2RMF
API_PLAYGROUND_AUTO_INJECT_STOREFRONT_KEY=trueAccess Points
Once verified, access the APIs at:
- API Documentation: https://your-domain.com/api
- REST API (Shop): https://your-domain.com/api/shop
- REST API (Admin): https://your-domain.com/api/admin
- GraphQL Endpoint:
https://your-domain.com/api/graphql - GraphQL Playground: https://your-domain.com/api/graphiql
Troubleshooting
Provider Not Found
Error: Class 'Webkul\BagistoApi\Providers\BagistoApiServiceProvider' not found
Solution:
composer dump-autoload
php artisan cache:clear
php artisan config:clear404 Errors on API Endpoints
Error: API endpoints return 404 Not Found
Solutions:
- Ensure routes are published:
php artisan vendor:publish --tag=routes - Clear route cache:
php artisan route:clear - Check
.htaccessfile is present in your web root - Verify
APP_URLin.envmatches your domain
Permission Denied Errors
Error: Permission denied on file operations
Solution:
# Set proper permissions
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
# If using Docker/VM
chown -R www-data:www-data storage bootstrapDatabase Connection Errors
Error: SQLSTATE[HY000]: General error: 1030 Got error
Solutions:
- Verify database credentials in
.env - Run migrations:
php artisan migrate - Check database encoding:
utf8mb4 - Ensure sufficient disk space
Rate Limiting Issues
Error: 429 Too Many Requests
Solutions:
- Check rate limit configuration:
php artisan config:show bagisto-api - Update rate limit in
.env:BAGISTO_API_RATE_LIMIT=200 - Clear rate limit cache:
php artisan cache:forget rate_limit
CORS Errors in Browser
Error: Access to XMLHttpRequest blocked by CORS policy
Solutions:
- Verify CORS is configured in
config/cors.php - Check
FRONTEND_URLenvironment variable - Ensure
supports_credentialsis set properly - Clear browser cache
Performance Optimization
Ensure the application is running in a production environment and that APP_DEBUG is set to false.
# Clear cached configuration and other optimized files
php artisan optimize:clear
# Rebuild and optimize caches
php artisan optimizeWhat's Next?
Ready to start using the APIs?
- 🔐 Authentication Guide - Learn about authentication methods
- 🔗 REST API Guide - Explore REST API endpoints
- ⚡ GraphQL API Guide - Discover GraphQL capabilities
- 🔑 API Key Management - Generate and manage API keys

