Creating Your Own Package

Creating the Package

Commands

1
php artisan cms:command:make {vendor} {package} {commandName}
2
php artisan cms:migration:make {vendor} {package} {migrationName}
3
php artisan cms:model:make {vendor} {package} {modelName}
4
php artisan cms:module:create {name}
5
php artisan cms:module:update {oldName} {newName}
6
php artisan cms:module:delete {name}
Copied!

Package Configuration File

1
/packages/{vendorName}/{packageName}/src/{packageName}.php
Copied!
You will find your package file within the above path. Below are different configuration options.
syncPermissions()
Here is an example from the Notifications package. We recommend sticking to the prefix {packageName}.admin.{controllerName}.{actionName} syntax to be consistent. The name of your permission must also match the route name it corresponds to.
1
<?php
2
3
namespace Adaptcms\Notifications;
4
5
use Adaptcms\Auth\Models\Permission;
6
7
class Notifications
8
{
9
/**
10
* Sync Permissions
11
*
12
* @return void
13
*/
14
public function syncPermissions()
15
{
16
$permissions = [
17
// admin
18
'notifications.admin.settings.edit',
19
20
// frontend
21
'notifications.front.settings.edit'
22
];
23
24
Permission::syncPackagePermissions($permissions);
25
}
Copied!
registerAdminSettingsPage()
Another example is from the Notifications package. Simply pass the vendor name, package name, and permission/route name.
1
<?php
2
3
namespace Adaptcms\Notifications;
4
5
use Adaptcms\Base\Models\Setting;
6
7
class Notifications
8
{
9
/**
10
* Register Admin Settings Page
11
*
12
* @return void
13
*/
14
public function registerAdminSettingsPage()
15
{
16
Setting::registerAdminSettingsPage('Adaptcms', 'Notifications', 'notifications.admin.settings.edit');
17
}
Copied!
registerFrontSettingsPage()
1
<?php
2
3
namespace Adaptcms\Notifications;
4
5
use Adaptcms\Base\Models\Setting;
6
7
class Notifications
8
{
9
/**
10
* Register Front Settings Page
11
*
12
* @return void
13
*/
14
public function registerFrontSettingsPage()
15
{
16
Setting::registerFrontSettingsPage('Adaptcms', 'Notifications', 'notifications.front.settings.edit');
17
}
Copied!
onInstall()
This method is required to at least register the package with the CMS. You may put in whatever you want for code that is needed, such as calling an install command for your package, within the onInstall method.
1
<?php
2
3
namespace Adaptcms\Notifications;
4
5
use Adaptcms\Base\Models\Package;
6
7
class Notifications
8
{
9
/**
10
* On Install
11
*
12
* @return void
13
*/
14
public function onInstall()
15
{
16
Package::syncPackageFolder(get_class());
17
}
Copied!

Package Options

Vue Plugin File(s)

You may create a plugin or numerous plugins inside your package's UI folder. In the UI folder simply create a folder called plugins and any JS files in this folder will be autoloaded and globally usable. Please use Vue conventions to have this plugin able to be registered. Users may see an example in the Base package here:
1
/packages/Adaptcms/Base/ui/plugins/Base.js
Copied!
Last modified 3mo ago