# Creating Your Own Package

### Creating the Package

#### Commands

```
php artisan cms:command:make {vendor} {package} {commandName}
php artisan cms:migration:make {vendor} {package} {migrationName}
php artisan cms:model:make {vendor} {package} {modelName}
php artisan cms:module:create {name}
php artisan cms:module:update {oldName} {newName}
php artisan cms:module:delete {name}
```

#### Package Configuration File

```
/packages/{vendorName}/{packageName}/src/{packageName}.php
```

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.

```
<?php

namespace Adaptcms\Notifications;

use Adaptcms\Auth\Models\Permission;

class Notifications
{
  /**
  * Sync Permissions
  *
  * @return void
  */
  public function syncPermissions()
  {
    $permissions = [
      // admin
      'notifications.admin.settings.edit',
  
      // frontend
      'notifications.front.settings.edit'
    ];
  
    Permission::syncPackagePermissions($permissions);
  }
```

**registerAdminSettingsPage()**

Another example is from the Notifications package. Simply pass the vendor name, package name, and permission/route name.

```
<?php

namespace Adaptcms\Notifications;

use Adaptcms\Base\Models\Setting;

class Notifications
{
  /**
  * Register Admin Settings Page
  *
  * @return void
  */
  public function registerAdminSettingsPage()
  {
    Setting::registerAdminSettingsPage('Adaptcms', 'Notifications', 'notifications.admin.settings.edit');
  }
```

**registerFrontSettingsPage()**

```
<?php

namespace Adaptcms\Notifications;

use Adaptcms\Base\Models\Setting;

class Notifications
{
  /**
  * Register Front Settings Page
  *
  * @return void
  */
  public function registerFrontSettingsPage()
  {
    Setting::registerFrontSettingsPage('Adaptcms', 'Notifications', 'notifications.front.settings.edit');
  }
```

**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.

```
<?php

namespace Adaptcms\Notifications;

use Adaptcms\Base\Models\Package;

class Notifications
{
  /**
  * On Install
  *
  * @return void
  */
  public function onInstall()
  {
    Package::syncPackageFolder(get_class());
  }
```

### 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:

```
/packages/Adaptcms/Base/ui/plugins/Base.js
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.adaptcms.com/adaptcms/advanced/creating-your-own-package.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
