Download the PHP package statamic/eloquent-driver without Composer

On this page you can find all versions of the php package statamic/eloquent-driver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eloquent-driver

Statamic Eloquent Driver

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

Installation & Usage

You can install and configure the Eloquent Driver using a single command:

The command will install the statamic/eloquent-driver package, publish the config file, then prompt you to select which repositories you wish to move to the database. The command will then publish the relevant migrations and run php artisan migrate behind the scenes.

The command will also give you the opportunity to indicate whether you'd like existing data to be imported.

Importing flat-file content

If you originally opt-out of importing existing content, then later change your mind, you can import existing content by running the relevant commands:

Assets

Empty Folders

If your assets are being driven by the Eloquent driver then the database is used as the source of truth for the folder listing, so if no file is present inside a folder then it will not be shown.

Syncing

If your assets are being driven by the Eloquent Driver and you're managing your assets outside of Statamic (eg. directly in the filesystem), you should run the php please eloquent:sync-assets command to add any missing files to the database, and remove files that no longer exist on the filesystem.

Exporting to flat files

If you wish to move back to flat-files, you may use the following commands to export your content out of the database:

Configuration

The configuration file, found in config/statamic/eloquent-driver.php is automatically published when you install the Eloquent Driver.

For each of the repositories, it allows you to determine if they should be driven by flat-files (file) or Eloquent (eloquent). Some repositories also have additional options, like the ability to override the model used.

Using dedicated columns for data

Note: This feature is currently only available for Entries.

By default, the Eloquent Driver stores all data in a single data column. However, it is possible to store fields in their own columns.

  1. First, you'll need to enable the map_data_to_columns option in the entries section of the configuration file:

  2. Create a new migration to add the columns to the entries table:

    You should ensure that the column names match the field handles in your blueprints. You should also ensure the column type matches that of the fieldtype. As a general rule of thumb, here are some common mappings:

    • Text fields should be stored as string columns.
    • Relationship fields should be stored as json columns. (Unless max_items is set to 1, in which case it should be stored as a string column.)
    • Number fields should be stored as integer or decimal columns.
  3. Run the migration:

  4. If you're adding json or integer columns, you will need to provide your own Entry model in order to set the appropriate casts. You can do this by creating a new model which extends the default Entry model:

    If you're using UUIDs as your entry IDs (which is the default if you imported existing entries into the database), you should extend the Statamic\Eloquent\Entries\UuidEntryModel class instead:

  5. If you have existing entries, you will need to re-save them to populate the new columns. You can do this by pasting the following snippet into php artisan tinker:

  6. And that's it! Statamic will now read and write data to the new columns in the entries table, rather than the data column.

Upgrading

After updating to a new version of the Eloquent Driver, please ensure you run php artisan migrate to update your database to the latest schema.

Questions

Can I store users in the database too?

By default, Statamic users live in the users directory of your project. If you wish to move them to the database, please follow this guide.

Can I store some collections in the database, while keeping others in flat-files?

This driver does not make it possible to have some collections flat-file driven and others Eloquent driven. If you're looking for that, you may want to checkout the Runway addon, which is part of The Rad Pack.


All versions of eloquent-driver with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
statamic/cms Version ^5.18
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package statamic/eloquent-driver contains the following files

Loading the files please wait ....