All Projects → nerds-and-company → Schematic

nerds-and-company / Schematic

Licence: mit
Craft Setup Sync

Projects that are alternatives of or similar to Schematic

Craft Sitemap
Craft plugin to generate a sitemap.
Stars: ✭ 105 (-25%)
Mutual labels:  craft-plugin, craft
Craft Preparse Field
Field type that parses twig when an element is saved.
Stars: ✭ 103 (-26.43%)
Mutual labels:  craft-plugin, craft
craft.patrol
Patrol simplifies SSL and maintenance routing for sites built with Craft
Stars: ✭ 90 (-35.71%)
Mutual labels:  craft, craft-plugin
Craft.patrol
Patrol simplifies SSL and maintenance routing for sites built with Craft
Stars: ✭ 91 (-35%)
Mutual labels:  craft-plugin, craft
craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (-80.71%)
Mutual labels:  craft, craft-plugin
craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (-88.57%)
Mutual labels:  craft, craft-plugin
craft3-seeder
Seeder is the easiest way to quickly create placeholder content while you're building out a website. Create your sections & fields and then let Seeder make entries for you.
Stars: ✭ 30 (-78.57%)
Mutual labels:  craft, craft-plugin
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (-72.14%)
Mutual labels:  craft, craft-plugin
craft-plugin-mix
Helper plugin for Laravel Mix in Craft CMS templates
Stars: ✭ 50 (-64.29%)
Mutual labels:  craft, craft-plugin
craft-instagram-feed
Craft CMS plugin to receive Instragram feed data as variable in templates
Stars: ✭ 25 (-82.14%)
Mutual labels:  craft, craft-plugin
Buttonbox
A collection of utility field types for Craft
Stars: ✭ 94 (-32.86%)
Mutual labels:  craft-plugin, craft
Craft Brief
Quick, easy, and customizable user-group notifications for Craft CMS.
Stars: ✭ 47 (-66.43%)
Mutual labels:  craft-plugin, craft
overflow.craft-plugin
A plain text Craft field type, with a soft or hard character limit.
Stars: ✭ 13 (-90.71%)
Mutual labels:  craft, craft-plugin
craft-json-snippets
Helps make CraftCMS models in .json
Stars: ✭ 17 (-87.86%)
Mutual labels:  craft, craft-plugin
oembed
A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.
Stars: ✭ 34 (-75.71%)
Mutual labels:  craft, craft-plugin
craft-wheelform
Craft CMS 4 Form with Database integration
Stars: ✭ 64 (-54.29%)
Mutual labels:  craft, craft-plugin
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (-81.43%)
Mutual labels:  craft, craft-plugin
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (-87.14%)
Mutual labels:  craft, craft-plugin
picpuller-for-craft3
Pic Puller for Craft 3 lets authorized users pull in their Instagram media into Craft.
Stars: ✭ 12 (-91.43%)
Mutual labels:  craft, craft-plugin
Awesome
A collection of awesome Craft CMS plugins, articles, resources and shiny things.
Stars: ✭ 449 (+220.71%)
Mutual labels:  craft-plugin, craft

Schematic (for Craft 3) Scrutinizer Code Quality Build Status Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

Schematic allows you to synchronize your Craft setup over multiple environments. It does this by exporting information about assets, database (fields, sections, users), locales and plugins to a YAML file that can be imported in other environments.

❗️ Craft 3.1 notice

Craft 3.1 brings project config that will deliver most if not all schematic functionality natively. We will continue to support schematic going forward, but it seems likely to become obsolete.

Currently Schematic will not run on Craft 3.1 or higher!

Installation

This tool can be installed using Composer. Run the following command from the root of your project:

composer require nerds-and-company/schematic

This will add nerds-and-company/schematic as a requirement to your project's composer.json file and install the source-code into the vendor/nerds-and-company/schematic directory.

Schematic is now available as an installable plugin in Craft. You can install it in the cp or use ./craft install/plugin schematic

Usage

Basic usage

The most common usage pattern of this tool, to synchronize from a development to a production environment, would be:

  1. Create a Craft project locally
  2. Set up all of the desired plugins, sections, templates, etc.
  3. Run a Schematic export locally
  4. Optionally, if a revision control system is used, commit the schema file to the local repository
  5. Deploy the Craft application to a production environment
  6. Run a Schematic import remotely

Or, to synchronize from a production to a development environment:

  1. Run a Schematic export remotely
  2. Pull the schema file locally
  3. Optionally, if a revision control system is used, commit the schema file to the local repository
  4. Run a Schematic import locally

Exporting

An export can be created by running:

./craft schematic/export

To skip exporting a specific of data type, exclusions can be specified in the following form:

./craft schematic/export --exclude=volumes

Multiple exclusions can also be specified:

./craft schematic/export --exclude=volumes,categoryGroups

The same goes for only exporting a subset of data types:

./craft schematic/export --include=volumes,categoryGroups

See [Supported DataTypes](#Supported DataTypes)

An export will generate a schema file at config/schema.yml. The file path can be changed using the --file flag, for instance craft schematic/export --file=path/to/my-schema.yml

Importing

To run an import with schematic, a schema file needs to be present. An import can be created by running:

./craft schematic/import

By default schematic will look at config/schema.yml. To change the path where schematic will look for the schema file, use the --file flag.

Optionally the --force flag can be used to make the import delete any items which are not mentioned in the import file.

WARNING!! This will also delete any related content.

To skip importing a specific of data type, exclusions can be specified in the following form:

./craft schematic/import --exclude=volumes

Multiple exclusions can also be specified:

./craft schematic/import --exclude=volumes,categoryGroups

See [Supported DataTypes](#Supported DataTypes)

Supported DataTypes

Here is a list of all of the data types and their corresponding exclude parameter values:

Data Type Exclude/Include Parameter
plugins plugins
Sites sites
Asset Transforms assetTransforms
Category Groups categoryGroups
Element Indexes elementIndexSettings
Email Settings emailSettings
Fields fields
General Settings generalSettings
Global Sets globalSets
Plugins plugins
Sections sections
Tag Groups tagGroups
User Settings userSettings
User Groups userGroups
Volumes volumes

Overrides and environment variables

Specific keys can be overriden by adding a key in config/override.yml and setting the corresponding environment variable. The key name in the override.yml needs to be the same as the key you want to override from schema.yml, including any parent key names.

The override file is also applied back when exporting, so your variables are not overriden by actual values. Schematic also supports passing an override file using the --override-file flag, for instance: ./craft schematic/import --override-file=path/to/your/config/override.yml.

Example

If the following override.yml is defined:

parent:
    key_name: %KEY_VALUE%

Then the environment variable KEY_VALUE needs to be set. The value of this environment variable will override the key key_name. If the environment variable is not set Schematic will throw an error.

Environment variables can also directly be used in the schema.yml file. Beware that if you do that, they will be overriden on export by their environment variable's values.

Events

Custom converters can be injected with the EVENT_RESOLVE_CONVERTER event. This can be especially useful for importing and exporting custom field types. The converters need to implement the NerdsAndCompany\Schematic\Interfaces\ConverterInterface.

Event::on(Schematic::class, Schematic::EVENT_RESOLVE_CONVERTER, function (ConverterEvent $event) {
    if ($event->modelClass = "My\Custom\Field") {
      $event->converterClass = "My\Custom\FieldConverter";
    }
});

Custom source mappings can be injected with the EVENT_MAP_SOURCE event. This can be especially useful for importing and exporting custom sources.

Event::on(Schematic::class, Schematic::EVENT_MAP_SOURCE, function (SourceMappingEvent $event) {
    list($sourceType, $sourceFrom) = explode(':', $event->source);

    switch ($sourceType) {
        case 'plugin-source':
            $event->service = Craft::$app->customService;
            $event->method = 'getCustomModelBy';
            break;
    }
});

Caveats

Schematic uses handles to identify content. When a handle is changed in the schema file and import is run with force a new content type will be created with that handle, and the old content type will be deleted!

It is recommended to change content type handles with craft content migrations and to run these migration before running a schematic import.

License

This project has been licensed under the MIT License (MIT). Please see License File for more information.

Changelog

CHANGELOG.md

Credits

Inspired and based on the awesome ArtVandelay Plugin and built by these awesome individuals

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].