Skip to content

v2.0.0

Latest

Choose a tag to compare

@ryangjchandler ryangjchandler released this 03 Nov 20:36
25eb2c1

Orbit 2.0 is a rework of the package around type safety and a simpler, more reliable storage engine. Your content files are now the source of truth, and the SQLite database is a cache that Orbit rebuilds from them.

Upgrading from 1.x? Read the upgrade guide first. Orbit 2.0 requires PHP 8.3+ and Laravel 13.

Highlights

  • Files are the source of truth.
    • On the first query of each request, Orbit checks each model's files and schema and rebuilds that model's cache if anything changed, including files edited or deleted by hand.
    • Saves, deletes and increments write the model's file inside a transaction, including quiet saves. If the file can't be written, the change is rolled back.
    • Files that can't be parsed are skipped with a warning instead of breaking every query.
  • orbit:cache for production. Run it on deploy to build the cache and stop checking files for changes. orbit:clear resets it.
  • Readable files.
    • Array casts are written as real lists and maps, and dates as ISO 8601 strings. null values are left out.
    • A file without a key uses its file name, so hand-written files like content/posts/hello-world.md work with a string key.
  • Single-file storage. The new FlatJson driver stores all of a model's records in one file, such as content/posts.json. Custom drivers can do the same by implementing Orbit\Contracts\SingleFile (thanks @godismyjudge95).
  • Multitenancy. A model can return a different table and directory per tenant from getTable() and getOrbitSource(), and each gets its own cache.
  • Laravel's SoftDeletes now works directly. Soft deleting writes deleted_at to the file.

Breaking changes

  • Models must implement Orbit\Contracts\Orbit alongside the Orbital trait.
  • schema() is now an instance method with a void return type.
  • Drivers are chosen by class name from getOrbitDriver(). $driver, getOrbitalDriver() and Orbit::extend() are gone.
  • Custom drivers implement the new Orbit\Contracts\Driver interface, and FileDriver has been removed.
  • getOrbitalName() is now getOrbitSource(), and getOrbitalPathPattern() has been removed.
  • Orbit\Concerns\SoftDeletes has been removed in favour of Laravel's trait.
  • orbit:clear no longer asks for confirmation, and its --force option has been removed.

See the upgrade guide for details and code examples.

Fixed since 1.x

  • Many-to-many relationships through an Orbit pivot model no longer fail with "no such table" when the relationship is empty (#116).
  • Array and JSON casts are no longer double-encoded when the cache is rebuilt (#171).
  • The _orbit_meta "table already exists" error can no longer happen (#153).
  • Filament table summaries and withCount() between Orbit models work (#156).

Known limitations

  • Query-level writes such as Post::where('draft', true)->delete() don't load models, so they don't update files. Load the models and save or delete each one instead.
  • morphToMany relationships through an Orbit pivot model aren't covered by the many-to-many fix yet.

Changes since v2.0.0-rc1: v2.0.0-rc1...v2.0.0