- Can I use Orbit for a production Laravel app with 50K+ records?
- Orbit isn’t optimized for large datasets. File I/O becomes a bottleneck around 10K–20K records, and flat files risk corruption. For production, test performance with `dd()` or Telescope first. If scaling beyond 1GB, consider hybrid storage (e.g., SQLite for metadata + Orbit for blobs).
- How do I migrate an existing Laravel app from MySQL to Orbit?
- Export data to JSON/CSV, then use `OrbitSeeder` to import it into files. Update model configurations to use the `orbit` connection in `config/database.php`. Start with non-critical models (e.g., `Settings`, `StaticPages`) to validate the migration. Use `php artisan orbit:migrate` for schema adjustments.
- Does Orbit support Laravel’s soft deletes?
- Soft deletes require manual implementation. Orbit doesn’t natively support them, but you can override the `delete()` method in your model to mark records as deleted (e.g., add a `deleted_at` field to your schema) and filter queries with `whereNull('deleted_at')`.
- How do I secure sensitive data stored in Orbit files?
- Use the `OrbitEncryptor` to encrypt fields before storage. Configure it in your model’s `schema()` method with `table->encrypted('field_name')`. Encrypted data is stored as base64-encoded blobs, but decryption happens transparently during queries. Never store raw secrets in Orbit files.
- Will Orbit work with Laravel Forge/Vapor deployments?
- Yes, Orbit is ideal for serverless or edge deployments like Laravel Vapor. Files are stored locally (e.g., `/storage/app/orbit`), so no database provisioning is needed. Ensure the storage path is writable and persistent across deployments. For multi-server setups, use a shared filesystem like S3 with the `path` config.
- Can I use Orbit alongside MySQL/PostgreSQL in the same app?
- Absolutely. Define multiple database connections in `config/database.php` and route models dynamically. For example, use `protected $connection = 'orbit'` in models for flat-file storage, while keeping transactional data in MySQL. Orbit integrates seamlessly with Eloquent’s connection system.
- How do I handle concurrent writes to Orbit files?
- Orbit isn’t thread-safe by default. For multi-process writes, implement locking with PHP’s `flock()` or use Laravel’s queue system to serialize writes. Example: Wrap `create()`/`update()` calls in a queue job. Avoid concurrent writes from multiple servers without coordination.
- Does Orbit support Eloquent relationships (hasMany, belongsTo)?
- Yes, but with limitations. Relationships are stored as nested JSON in the parent file (e.g., `posts` file contains `author_id` and `comments` array). Complex queries like `hasManyThrough` may require manual denormalization. For deep relations, consider pre-computing data or using a hybrid database setup.
- What Laravel versions and PHP requirements does Orbit support?
- Orbit officially supports Laravel 10+ and PHP 8.1+. While the README mentions Laravel 9.x and PHP 8.0, those versions may lack optimizations or bug fixes. Test thoroughly if using older versions. PHP 8.1+ is recommended for performance and type safety features used by Orbit.
- How do I back up Orbit data?
- Back up files manually (e.g., `cp -r storage/app/orbit backup/`) or automate with a cron job. Orbit files are self-contained, so no database dumps are needed. For critical data, implement a checksum validation system to detect corruption. Avoid relying on filesystem snapshots if files exceed 1GB.