Download the PHP package dnadesign/silverstripe-populate without Composer

On this page you can find all versions of the php package dnadesign/silverstripe-populate. 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 silverstripe-populate

Populate Module

Build Status

This module provides a way to populate a database from YAML fixtures and custom classes. For instance, when a building a web application the pages and default objects can be defined in YAML and shared around developers. This extends the requireDefaultRecords concept in SilverStripe's DataModel.

Requirements

Installation Instructions

This module must only ever be used in your development environment, and should never be used on production. While there is code to prevent it from being run in production, it is not fool-proof and therefore you must never run this module in production. Install it as a dev dependency in composer like so:

Setup

First create a new yml config file in your config directory app/_config/populate.yml (or add it to an existing config.yml file if you prefer).

If you're sharing test setup with populate, you can specify any number of paths to load fixtures from.

An example app/fixtures/populate.yml might look like the following:

Out of the box, the records will be created on when you run the PopulateTask through /dev/tasks/PopulateTask/. To make it completely transparent to developers during the application build, you can also include this to hook in on requireDefaultRecords as part of dev/build by including the following in one of your application models requireDefaultRecords methods:

Configuration options

include_yaml_fixtures

An array of YAML files to parse.

mysite/_config/app.yml

truncate_objects

An array of ClassName's whose instances are to be removed from the database prior to importing. Useful to prevent multiple copies of populated content from being imported. It's recommended to truncate any objects you create, to ensure you can re-run PopulateTask as often as you want during development and get a consistent database state. This supports Versioned objects (like SiteTree) and Fluent (if the module is installed).

truncate_tables

An array of tables to be truncated. Useful when there's no relation between your populated classes and the table you want truncated

See Updating Records if you wish to merge new and old records rather than clearing all of them.

YAML Format

Populate uses the same FixtureFactory setup as SilverStripe's unit testing framework. The basic structure of which is:

Relations are handled by referring to them by their reference value:

See SilverStripe's fixture documentation for more advanced examples, including $many_many and $many_many_extraFields.

Any object which implements the Versioned extension will be automatically published.

Basic PHP operations can also be included in the YAML file. Any line that is wrapped in a ` character and ends with a semi colon will be evaled in the current scope of the importer.

Updating Records

If you do not truncate the entire table, the module will attempt to first look up an existing record and update that existing record. For this to happen the YAML must declare the fields to match in the look up. You can use several options for this.

PopulateMergeWhen

Contains a WHERE clause to match e.g "URLSegment = 'home' AND ParentID = 0".

PopulateMergeMatch

Takes a list of fields defined in the YAML and matches them based on the database to avoid repeating content

PopulateMergeAny

Takes the first record in the database and merges with that. This option is suitable for things like SiteConfig where you normally only contain a single record.

If the criteria meets more than 1 instance, all instances bar the first are removed from the database so ensure you criteria is specific enough to get the unique field value.

Default Assets

The script also handles creating default File and image records through the PopulateFileFrom flag. This copies the file from another path (say mysite) and puts the file inside your assets folder.

Extensions

The module also provides extensions that can be opted into depending on your project needs

PopulateMySQLExport

This extension outputs the result of the Populate::requireDefaultRecords() as a SQL Dump on your local machine. This speeds up the process if using Populate as part of a test suite or some other CI service as instead of manually calling the task (which will use the ORM) your test case can be fed raw MySQL to import and hopefully speed up execution times.

To apply the extension add it to Populate, configure the path, flush, then run dev/tasks/PopulateTask

Publish configuration

By default the module uses publishSingle() to publish records. If, for whatever reason, you would prefer to that the module uses publishRecursive(), you can enable this by settings the following configuration:

Allow Populate to run on "live" environments

DANGER ZONE: Please understand that you are about to provide admins with the ability to run Populate on your production environment. Before setting this configuration you should understand and accept the risks related to the loss of production data.

Credits

silverstripe-populate was originally created by wilr and DNA Design.


All versions of silverstripe-populate with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
silverstripe/framework Version ^5
silverstripe/versioned Version ^2
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 dnadesign/silverstripe-populate contains the following files

Loading the files please wait ....