Skip to content

A Concrete CMS package for cleaning existing sites or seeding new ones

Notifications You must be signed in to change notification settings

concretecms/fresh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

So Fresh and so Clean

The concrete5 fresh package makes it simple to clean a database or seed it with fresh data.

Usage

Fresh adds two new commands to a concrete5 install:

  • concrete5 fresh:clean [cleaner?] To clean (destroy) data and leave you with something clean that is safer to share
  • concrete5 fresh:seed [seeder?] To seed data into your concrete5 install

Examples

Seeders use the fresh::seeders config group and Cleaners use fresh::cleaners. Overrides for these settings will likely end up in application/config/fresh/seeders.php and application/config/fresh/cleaners.php.

Clean the site

$ ./vendor/bin/concrete5 fresh:clean

Seed 5 admins and 15 users into your site

$ ./vendor/bin/concrete5 c5:config set fresh::seeders.admins 5
$ ./vendor/bin/concrete5 c5:config set fresh::seeders.users 15
$ ./vendor/bin/concrete5 fresh:seed

Seed or Clean using a custom seeder

This package can only seed using one seeder or Cleaner at a time. Luckily aggregate seeders and cleaners totally work.

./vendor/bin/concrete5 fresh:seed "\Some\Custom\Seeder"
./vendor/bin/concrete5 fresh:clean "\Some\Custom\Cleaner"

Customizing

Fresh is really easy to customize with your own cleaners / seeders. A few ways to get started are listed below

Quick and Dirty

If you're working to test something, or needing to quickly clean things from your install without permanent changes to your project, you may just want a simple entry point for custom functionality.

In your /application/bootstrap/app.php you can define your cleaner / seeder:

// Override `fresh::cleaners.cleaner` config entry
$app['config']['fresh::cleaners.cleaner'] = new Class() extends \PortlandLabs\Fresh\Clean\Cleaner {

    public function run()
    {
        $this->output->section('Custom Cleaner!');
    }
};

Maintainable and happy

Rather than making a quick and dirty anonymous class, let's use configuration to point to a class that exists in our namespace.

First make sure you have a class that exists in your namespace, in this example we're using \PortlandLabs\FooBaz\CleanRoutine.

Next override the fresh::cleaners.cleaner or the fresh::seeders.seeder config item

<?php

return [
    'cleaner' => '\PortlandLabs\FooBaz\CleanRoutine'
];

About

A Concrete CMS package for cleaning existing sites or seeding new ones

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages