• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Provides support for storing your Statamic data in a database, rather than flat files.

Statamic Eloquent Driver

This package provides support for storing your Statamic data in a database rather than the filesystem.

Installation

Install using Composer:

composer require statamic/eloquent-driver

Publish the config file:

php artisan vendor:publish --tag="statamic-eloquent-config"

Since Statamic uses UUIDs within content files by default, we provide two solutions depending on whether you need to use existing content.

Fresh install of statamic/statamic (using incrementing ids)

If you're starting from scratch, we can use traditional incrementing integers for IDs.

  • Delete content/collections/pages/home.md
  • Change the structure tree in content/trees/collections/pages.yaml to {}.
  • Run php artisan vendor:publish --provider="Statamic\Eloquent\ServiceProvider" --tag=migrations.
  • Run php artisan vendor:publish --tag="statamic-eloquent-entries-table".
  • Run php artisan migrate.

Starting from an existing site (using UUIDs)

If you're planning to use existing content, we can use the existing UUIDs. This will prevent you from needing to update any data or relationships.

  • In the config/statamic/eloquent-driver.php file, change entries.model to \Statamic\Eloquent\Entries\UuidEntryModel::class.
  • Run php artisan vendor:publish --provider="Statamic\Eloquent\ServiceProvider" --tag=migrations.
  • Run php artisan vendor:publish --tag="statamic-eloquent-entries-table-with-string-ids".
  • Run php artisan migrate.

Publishing migrations seperately

Alternatively, you can publish each repository's migrations individually:

php artisan vendor:publish --tag="statamic-eloquent-asset-migrations"

php artisan vendor:publish --tag="statamic-eloquent-blueprint-migrations"

php artisan vendor:publish --tag="statamic-eloquent-collection-migrations"

php artisan vendor:publish --tag="statamic-eloquent-form-migrations"

php artisan vendor:publish --tag="statamic-eloquent-global-migrations"

php artisan vendor:publish --tag="statamic-eloquent-navigation-migrations"

php artisan vendor:publish --tag="statamic-eloquent-revision-migrations"

php artisan vendor:publish --tag="statamic-eloquent-taxonomy-migrations"

Configuration

The configuration file (statamic.eloquent-driver) allows you to choose which repositories you want to be driven by eloquent. By default, all are selected, but if you want to opt out simply change driver from eloquent to file for that repository.

You may also specify your own models for each repository, should you wish to use something different from the one provided.

Upgrading

After upgrading please ensure to run php artisan migrate to update your database to the latest schema.

Importing existing file based content

We have provided imports from file based content for each repository, which can be run as follows:

  • Assets: php please eloquent:import-assets
  • Blueprints and Fieldsets: php please eloquent:import-blueprints
  • Collections: php please eloquent:import-collections
  • Entries: php please eloquent:import-entries
  • Forms: php please eloquent:import-forms
  • Globals: php please eloquent:import-globals
  • Navs: php please eloquent:import-navs
  • Revisions: php please eloquent:import-revisions
  • Taxonomies: php please eloquent:import-taxonomies

If your assets are eloquent driver and you are managing your assets outside of Statamic, we have provided a sync assets command which will check your container for updates and add database entries for any missing files, while removing any that no longer exist.

php please eloquent:sync-assets

Exporting back to file based content

We have provided exports from eloquent to file based content for each repository, which can be run as follows:

  • Assets: php please eloquent:export-assets
  • Blueprints and Fieldsets: php please eloquent:export-blueprints
  • Collections: php please eloquent:export-collections
  • Entries: php please eloquent:export-entries
  • Forms: php please eloquent:export-forms
  • Globals: php please eloquent:export-globals
  • Navs: php please eloquent:export-navs
  • Revisions: php please eloquent:export-revisions
  • Taxonomies: php please eloquent:export-taxonomies

Storing Users in a Database

Statamic has a built-in users eloquent driver if you'd like to cross that bridge too.

Mixed driver entries and collections

This driver does not make it possible to have some collections/entries file driven and some eloquent driven. If that is your requirement you may want to look into using Runway.

More Repositories

1

cms

The core Laravel CMS Composer package
PHP
3,674
star
2

statamic

Statamic: The New Site/App Package
PHP
713
star
3

ssg

The official Statamic Static Site Generator
PHP
230
star
4

awesome

A collection of awesome Statamic articles, links, resources and other rad things.
160
star
5

docs

Statamic Documentation
PHP
115
star
6

starter-kit-cool-writings

Statamic Starter Kit: Cool Writings
Antlers
109
star
7

spock

Automatically perform git commits, pushes, and other cli actions when Statamic content changes
PHP
95
star
8

v2-hub

Statamic 2 - Feature Requests and Bug Reports
95
star
9

starter-kit-starters-creek

Statamic Starter Kit: Starter's Creek
CSS
88
star
10

cli

Install and manage your Statamic projects from the command line.
PHP
71
star
11

v2-addons

Addons for Statamic v2
59
star
12

v2-docs

Statamic v2 Documentation
54
star
13

seo-pro

An all-in-one site reporting, metadata wrangling, Open Graph managing, Twitter card making, sitemap generating, turn-key addon for Statamic.
PHP
52
star
14

statamic-cheat-sheet

Cheat sheet of all tags and variables available in Statamic.
CSS
50
star
15

Theme-Kindling

Base starting point for building your custom Statamic site or theme.
CSS
44
star
16

migrator

Migrate from Statamic v2
PHP
43
star
17

wordpress-to-statamic-exporter

One-click WordPress plugin that converts all posts, pages, taxonomies, metadata, and settings to Statamic's JSON import format
PHP
43
star
18

starter-kit-doogie-browser

Statamic Starter Kit: Doogie Browser
JavaScript
40
star
19

i18n

Language translations for the Statamic v2 Control Panel
PHP
38
star
20

collaboration

Real-time, multi-user editing with Statamic via websockets
JavaScript
33
star
21

hosts

A list of web hosts that work well with Statamic right out of the box.
32
star
22

ideas

πŸ’‘Discussions on ideas and feature requests for Statamic
31
star
23

theme-storyteller

Statamic 2 Theme: Storyteller
JavaScript
26
star
24

preset-tailwindcss

DEPRECATED: Statamic 3 starts with TailwindCSS out of the box.
PHP
22
star
25

Check

Statamic's check-file. Checks to see if a server is capable of running Statamic or not.
PHP
19
star
26

Plugin-Image

Statamic Plugin for resizing images in your templates
PHP
19
star
27

Fieldtype-EpicEditor

Statamic Fieldtype for Epic Editor, a fullscreen Markdown editor
CSS
15
star
28

Addon-CP-Theme-Override

Override the CP Theme with a simple css file.
CSS
13
star
29

Plugin-Gist

Statamic Plugin for quick embedding Gists
PHP
13
star
30

Plugin-SimplePie

A fast and easy-to-use RSS and Atom feed parsing plugin for Statamic.
PHP
13
star
31

Plugin-Disqus

Disqus plugin for Statamic
PHP
13
star
32

importers

PHP
12
star
33

custom-publish-forms-eloquent

An example of using Custom Publish forms powered by Eloquent.
HTML
11
star
34

overload

CLI commands to create test and sample content.
PHP
11
star
35

starter-kit-podcaster

Statamic Starter Kit: Podcaster
JavaScript
10
star
36

github-revisions

PHP
10
star
37

starter-kit-multisimplicity

A Multilingual focused Starter Kit for Statamic
HTML
9
star
38

exporter

Export data from Statamic V1
PHP
8
star
39

custom-publish-forms-api

An example of using Custom Publish forms powered by an API.
PHP
8
star
40

addon-section-links

Automatically creates a table-of-contents of sections on publish pages.
JavaScript
8
star
41

Plugin-Dribbble

Statamic Dribbble plugin to fetch and display content from Dribbble's API, including players, shots, and lists.
PHP
8
star
42

pdfcrowd

PHP
7
star
43

eloquent-entries-example

An example package that allows you to store Statamic entries in a database.
PHP
6
star
44

highlight

Highlight content on your page.
PHP
5
star
45

twitter

Twitter example addon for Statamic 3.
JavaScript
5
star
46

changelog-action

JavaScript
5
star
47

Campaign-Monitor-for-Raven

PHP
5
star
48

starter-kit-stumblr

Starter Kit: Stumblr – your very own Tumblr
Antlers
5
star
49

cp-edit-url

Generate link to go to the edit page in the control panel of currently viewed page.
PHP
4
star
50

definitely-not-v3

It's definitely not v3.
4
star
51

Theme-London-Wild

The Original London Wild Theme for Statamic
HTML
3
star
52

bardify

Convert Replicator fields to Bard fields
PHP
3
star
53

Theme-Denali

Denali Theme
HTML
3
star
54

Plugin-BaconIpsum

Statamic Plugin for generating delicious bacon ipsum placeholder content.
PHP
3
star
55

workshop

Create and edit entries, pages, and globals on the front-end of your site without the control panel.
PHP
3
star
56

a11y

Discuss and track opportunities to improve Statamic's accessibility
3
star
57

starter-kit-link-in-the-bio

Statamic Starter Kit: Link in the Bio
Blade
3
star
58

page-tree

JavaScript
2
star
59

rainforest

Rainforest is a simple Statamic utility theme to help you manage invoices.
PHP
2
star
60

Plugin-Snipplr

Statamic Plugin for quick embedding Snipplr snippets
PHP
2
star
61

.github

1
star
62

content-api-demo

Simple demo of the Statamic Content API
PHP
1
star
63

demo

Statamic Demo Site
PHP
1
star
64

podcast-categories

Statamic Fieldtype to manage iTunes Categories
Vue
1
star
65

stripe

Statamic v2 addon to simplify Stripe Checkout
PHP
1
star
66

another_date

Display a date other than the current date on your Statamic site.
PHP
1
star
67

wikilinks

Autolinks content wrapped in [braces], just like a wiki.
PHP
1
star
68

Bloodhound

A Statamic search add-on.
PHP
1
star
69

rucksack

PHP
1
star
70

Raven

Powerful and simple form add-on for Statamic
PHP
1
star
71

test-readme

Will be deleted soon. Pay no heed.
1
star