Skip to main content
This guide helps you upgrade Rest Generic Class to newer versions and migrate from older implementations.

Current Version

Rest Generic Class is currently at version 2.1.8.

Requirements

System Requirements

  • PHP: ^8.0 or higher
  • Laravel: ^12.0 or higher
Before upgrading, ensure your application meets these minimum requirements:

Upgrading the Package

Step 1: Update Composer

Update the package version in your composer.json:
Or require a specific version:

Step 2: Publish Updated Configuration

If the configuration structure has changed, republish the config file:
Using --force will overwrite your existing configuration file. Back up your current config/rest-generic-class.php before running this command if you have custom settings.

Step 3: Clear Caches

Clear all relevant caches:
If using Spatie permissions:

Step 4: Test Your Application

Run your test suite to ensure compatibility:
Manually test critical API endpoints, especially:
  • Filtering with oper parameters
  • Relation loading
  • Hierarchy queries (if used)
  • Export functionality (if used)
  • Permission checks (if using Spatie)

Migration Strategies

From Custom Implementation

If you’re migrating from a custom REST API implementation to Rest Generic Class:

1. Model Migration

Update your models to extend BaseModel:

2. Service Layer

Create service classes extending BaseService:

3. Controller Migration

Refactor controllers to extend RestController:

4. API Compatibility

Update API clients to use the new query format:
Or using GET with JSON-encoded parameters:

From MongoDB to SQL (or vice versa)

MongoDB to SQL

SQL to MongoDB

Ensure you have mongodb/laravel installed when using BaseModelMongo:

Configuration Migration

Environment Variables

If upgrading from an older version, ensure your .env file includes new variables:

Config File Updates

Compare your existing config/rest-generic-class.php with the published version:
Manually merge any custom settings from your backup.

Optional Dependencies

Rest Generic Class suggests several optional packages. Install based on your needs:

Excel Export

Required for: exportExcel() method

PDF Export

Required for: exportPdf() method

Permissions

Required for: Permission models, traits, and middleware

Module Support

Required for: Module-aware permissions

Compatibility Notes

Laravel 12.x

Rest Generic Class 2.1.8 requires Laravel 12.0 or higher. If you’re on an older Laravel version:
  1. Upgrade Laravel first: https://laravel.com/docs/12.x/upgrade
  2. Then upgrade Rest Generic Class

PHP 8.0+

The package requires PHP 8.0 or higher. Ensure your server meets this requirement:
If you’re on PHP 7.x, upgrade PHP before updating the package.

Breaking Changes

While the package maintains backward compatibility where possible, be aware of:
  1. Configuration structure changes - Always review config after updates
  2. New required constants - Some model constants may become required
  3. Deprecated methods - Check for deprecation notices in logs

Rollback Procedure

If you encounter issues after upgrading:

1. Restore Previous Version

2. Restore Configuration

3. Clear Caches

4. Report Issue

Open an issue on GitHub with:
  • Your Laravel version
  • Previous package version
  • New package version
  • Error messages
  • Steps to reproduce

Testing After Migration

Create a comprehensive test checklist:
  • Basic CRUD operations work
  • Filtering with oper functions correctly
  • Relations load properly
  • Pagination works
  • Hierarchy queries work (if used)
  • Export functions work (if used)
  • Permission checks pass (if using Spatie)
  • Caching behaves as expected (if enabled)
  • Multi-tenant isolation works (if applicable)
  • Custom service methods still function
  • Custom controller methods still function

Getting Help

If you encounter migration issues:
  1. Check the Troubleshooting guide
  2. Review the FAQ
  3. Consult the API Reference
  4. Open an issue on GitHub
  5. Include:
    • Laravel version
    • Package version (before and after)
    • PHP version
    • Error messages with full stack traces
    • Steps to reproduce the issue

Best Practices

Version Pinning

In production, pin to specific versions:
Avoid using ^ or * in production to prevent unexpected updates.

Staging Environment

Always test upgrades in a staging environment before production:
  1. Deploy to staging
  2. Run full test suite
  3. Manually test critical endpoints
  4. Monitor for errors
  5. Only then deploy to production

Incremental Updates

If you’re several versions behind, update incrementally:
This makes it easier to identify which version introduced an issue.

Next Steps

After successful migration: