Create a Package for Our Tasks

First, let’s create a package. Since we’re clearing the Concrete log as a part of this package, let’s call our package "Log Utilities". It will contain some tasks specifically related to Concrete log management.

Following the instructions within the packages section, create the "Log Utilities" package. Here's your package controller. Here's the file system for our package:

  • log_utilities
    • controller.php

And within that controller.php here’s our code:

<?php

namespace Concrete\Package\LogUtilities;

use Concrete\Core\Package\Package;

class Controller extends Package
{

    protected $appVersionRequired = '9.0';
    protected $pkgVersion = '0.5';
    protected $pkgHandle = 'log_utilities';
    protected $pkgAutoloaderRegistries = array(
        'src' => '\Concrete\Documentation\LogUtilities'
    );

    public function getPackageDescription()
    {
        return t("Adds additional tasks to your Concrete site for working with logs.");
    }

    public function getPackageName()
    {
        return t("Log Utilities");
    }

    public function install()
    {
        $pkg = parent::install();
        /**
         * Nothing here yet.
         */
    }
}

Note: we're using class autoloading to create a PHP namespace for Concrete\Documentation\LogUtilities, which will be the namespace for some support classes we will need to write.

Finally, here’s our package ready for install:

text

At this point, if we install the package we'll have a package with nothing in it. Let’s add a task to it.