PHPackages                             ctasca/mage-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. ctasca/mage-bundle

ActiveMagento2-module[Templating &amp; Views](/categories/templating)

ctasca/mage-bundle
==================

Easily create Magento/Adobe Commerce PHP/XML/JS files from a set of templates

v3.8.1(1y ago)263892MITPHPPHP &gt;=7.4

Since Dec 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ctasca/mage-bundle)[ Packagist](https://packagist.org/packages/ctasca/mage-bundle)[ RSS](/packages/ctasca-mage-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (21)Used By (0)

ctasca/mage-bundle
==================

[](#ctascamage-bundle)

[![License](https://camo.githubusercontent.com/c730e57d5153ebf281a8ad3ac71f24b3529c418ca6f181b8d2ecf7df56f12e51/687474703a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2f6c6963656e7365)](https://packagist.org/packages/phpstan/phpstan) [![PHP Version Require](https://camo.githubusercontent.com/916d0b93f1fd2dd3db65394e075ae19fa1c8cd878e7d18d28259fd15161dc266/687474703a2f2f706f7365722e707567782e6f72672f6261646765732f706f7365722f726571756972652f706870)](https://packagist.org/packages/badges/poser)

### Easily create Magento2/AdobeCommerce PHP/XML/JS files from a set of templates via the command-line.

[](#easily-create-magento2adobecommerce-phpxmljs-files-from-a-set-of-templates-via-the-command-line)

Allows you to define your own templates as well as the data provided at files' creation time.

\#1 Installation
----------------

[](#1-installation)

```
composer require --dev ctasca/mage-bundle
```

### \#2 Copy template files to Magento root dev/ directory

[](#2-copy-template-files-to-magento-root-dev-directory)

```
cd /vendor/ctasca/mage-bundle && composer run-script post-install-cmd
```

After executing the above command, check that `dev/` directory of your Magento installation contains a `mage-bundle/` directory.

### Enable the module

[](#enable-the-module)

```
bin/magento module:enable Ctasca_MageBundle
```

### Run `setup:upgrade` command

[](#run-setupupgrade-command)

```
bin/magento setup:upgrade
```

### Run `setup:di:compile` command (optional)

[](#run-setupdicompile-command-optional)

If Magento is running in `production` mode you will need to also run:

```
bin/magento setup:di:compile
```

Available commands
------------------

[](#available-commands)

```
bin/magento magebundle:module:create
```

#### Shortcut

[](#shortcut)

```
bin/magento m:modu:c
```

Creates a skeleton Magento module in app/code directory, generating the required registration.php and etc/module.xml files

---

```
bin/magento magebundle:controller:create
```

#### Shortcut

[](#shortcut-1)

```
bin/magento m:cont:c
```

Creates a Controller namespace and Action class in specified module. Developer is prompted to choose a router (either standard or admin), and an Action template from the ones available in `mage-bundle/http-controller` or `mage-bundle/adminhtml-http-controller` directories.

---

```
bin/magento magebundle:etc:xml:create
```

#### Shortcut

[](#shortcut-2)

```
bin/magento m:e:x:c
```

Creates an XML file in Company/Module/etc directory. Templates can be chosen after specifying the area where the template applies to.

---

```
bin/magento magebundle:model:set:create
```

#### Shortcut

[](#shortcut-3)

```
bin/magento m:m:s:c
```

Creates a Model, Resource Model and Collection classes in specified Company/Module.

---

```
bin/magento magebundle:repository:create
```

#### Shortcut

[](#shortcut-4)

```
bin/magento m:r:c
```

Creates all the required class for a Repository in specified Company/Module.

**IMPORTANT:** In order to create a repository a model implementing an interface must exist.

If you need a Repository when creating a model-set with the command `magebundle:model:set:create` you can choose a template that will also create a Model implementing an interface

This command creates the following:

- An API Interface for the repository
- An API Data Interface for the model (if it doesn't exist)
- An API Data Search Result Interface
- The repository Model implementing the repository Interface

Do not forget to add the preferences to your di.xml for the repository classes once created. For example:

```

```

---

```
bin/magento magebundle:model:create
```

#### Shortcut

[](#shortcut-5)

```
bin/magento m:mode:c
```

Creates a Model class in specified Company/Module. There is also the template to create an interface instead of a class.

---

```
bin/magento magebundle:block:create
```

#### Shortcut

[](#shortcut-6)

```
bin/magento m:b:c
```

Creates a template Block class in specified Company/Module.

---

```
bin/magento magebundle:helper:create
```

#### Shortcut

[](#shortcut-7)

```
bin/magento m:h:c
```

Creates a Helper class in specified Company/Module.

---

```
bin/magento magebundle:customer-data:create
```

#### Shortcut

[](#shortcut-8)

```
bin/magento m:cu:c
```

Creates a CustomerData class in specified Company/Module.

---

```
bin/magento magebundle:view-model:create
```

#### Shortcut

[](#shortcut-9)

```
bin/magento m:v:c
```

Creates a View Model class in specified Company/Module.

---

```
bin/magento magebundle:observer:create
```

#### Shortcut

[](#shortcut-10)

```
bin/magento m:o:c
```

Creates an Observer class in specified Company/Module.

---

```
bin/magento magebundle:plugin:create
```

#### Shortcut

[](#shortcut-11)

```
bin/magento m:p:c
```

Creates a Plugin class in specified Company/Module.

---

```
bin/magento magebundle:cron:create
```

#### Shortcut

[](#shortcut-12)

```
bin/magento m:cr:c
```

Creates a Cron class in specified Company/Module.

---

```
bin/magento magebundle:console-command:create
```

#### Shortcut

[](#shortcut-13)

```
bin/magento m:cons:c
```

Creates a Console Command class in specified Company/Module.

---

```
bin/magento magebundle:data-patch:create
```

#### Shortcut

[](#shortcut-14)

```
bin/magento m:d:c
```

Creates a Setup Data Patch class in specified Company/Module.

---

```
bin/magento magebundle:schema-patch:create
```

#### Shortcut

[](#shortcut-15)

```
bin/magento m:s:c
```

Creates a Setup Schema Patch class in specified Company/Module.

---

```
bin/magento magebundle:api-interface:create
```

#### Shortcut

[](#shortcut-16)

```
bin/magento m:a:c
```

Creates an API interface in specified Company/Module. Templates can be chosen after specifying the area where the template applies to.

For functional API interfaces, the generated file will be created in the Company/Module/Api directory

For data API interfaces, the generated file will be created in the Company/Module/Api/Data directory

---

```
bin/magento magebundle:jquery-widget:create
```

#### Shortcut

[](#shortcut-17)

```
bin/magento m:j:c
```

Creates a JQuery widget file in specified Company/Module. JS file will be created in the specified module's `view/$AREA/web/js` directory.

---

```
bin/magento magebundle:ui-component:create
```

#### Shortcut

[](#shortcut-18)

```
bin/magento m:u:c
```

Creates an Ui Component JS file in specified Company/Module. JS file will be created in the specified module's `view/$AREA/web/js` directory.

---

```
bin/magento magebundle:logger:create
```

#### Shortcut

[](#shortcut-19)

```
bin/magento m:l:c
```

Creates a Logger Handler and Logger classes files in specified Company/Module.

Log filename can be specified when executing this command.

---

```
bin/magento magebundle:js:mixin:create
```

#### Shortcut

[](#shortcut-20)

```
bin/magento m:j:m:c
```

Creates a JS mixin file in specified Company/Module. JS file will be created in the specified module's `view/$AREA/web/js` directory.

---

```
bin/magento magebundle:exception:create
```

#### Shortcut

[](#shortcut-21)

```
bin/magento m:e:c
```

Creates an Exception class in specified Company/Module.

Utilities commands
------------------

[](#utilities-commands)

```
bin/magento magebundle:util:encryptor
```

#### Shortcut

[](#shortcut-22)

```
bin/magento m:u:e
```

Encrypts/Decrypts a string using Magento crypt key

Setting custom working directory
--------------------------------

[](#setting-custom-working-directory)

By default, MageBundle creates files in the `app/code` directory and in the specified module's namespace

It is possible, to change this behaviour by creating a json file named `pwd.json` in the `$MAGENTO-ROOT/dev/mage-bundle` directory and specifying the directory (relative to magento root) where files will be created when executing MageBundle commands.

This can be useful, for example, when developing a module which is not located in `app/code` directory

### Important:

[](#important)

The directory specified in `pwd.json` must end with a forward-slash

#### pwd.json example:

[](#pwdjson-example)

```
{
  "pwd" : "packages/my-package/"
}
```

About template files:
---------------------

[](#about-template-files)

Template files are written in PHP version 8.1.

For example the `http-get-action-json-result.tpl.php` contains the following

```
{{php}}
declare(strict_types=1);

namespace {{namespace}};

use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Controller\Result\Json;

class {{class_name}} implements HttpGetActionInterface
{
    /**
     * @param RequestInterface $request
     * @param JsonFactory $jsonFactory
     */
    public function __construct(
        private readonly RequestInterface $request,
        private readonly JsonFactory $jsonFactory
    ){}

    /**
     * @return Json
     */
    public function execute(): Json
    {
        $jsonResponse = $this->jsonFactory->create();
        return $jsonResponse->setData([]);
    }
}
```

To set your own templates just place them in the `MAGENTO_ROOT/dev/mage-bundle/$TEMPLATES_DIRECTORY/` directory and choose the template when executing the magebundle create commands.

**Note:** When executing the `magebundle:etc:xml:create` command, files are generated with the same name as the template file.
To create your own templates, use the filename for the xml file to be generated appending \_\_$STRING to the template filename.
For example to define your own global acl.xml template, create, for example, the template file naming like so: acl\_\_custom.tpl.xml. Then simply place it in the dev/mage-bundle/etc/global directory and select it when executing the create command.

**IMPORTANT:** If a filename already exists in a module's directory, the create command will not be executed and an error is output to the console.
This is to prevent overwriting an existing file.

For a list of the templates defined within the module go to...

[The repository wiki page](https://github.com/ctasca/mage-bundle/wiki)

Templates Data Provider
-----------------------

[](#templates-data-provider)

It is possible to define your own templates as well as the data that are passed when these are generated.

In order to do so, simply create a JSON file in the `MAGENTO_ROOT/dev/mage-bundle/custom-data/#path-to-template#` directory, naming the file exactly as the template file that is being generated and defining a JSON Object with setter methods as keys and their corresponding values.

As an example, for XML files generated in `Company/Module/etc` directories, custom data should be stored in `MAGENTO_ROOT/dev/mage-bundle/custom-data/etc/#area#/#template_name#.tpl.json`

#### Example

[](#example)

```
{
  "setTestNamespace" : "\\Ctasca\\MageBundle\\Test",
  "setCustomDataArray" : ["First Value", "Second Value"]
}
```

After creating this JSON file, it will be possible to use the placeholder `{{test_namespace}}` in a template file.

As `setCustomDataArray` provides an array, this will be imploded with `PHP_EOL` separator. To use it in your template files you would use the placeholder: `{{custom_data_array}}`

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~118 days

Total

19

Last Release

649d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/41e1dd03169744d8705425d6e70ceb934fb157c4cca4011acb69b1b2daf25e3b?d=identicon)[ctascanw1](/maintainers/ctascanw1)

---

Top Contributors

[![ctasca](https://avatars.githubusercontent.com/u/1621171?v=4)](https://github.com/ctasca "ctasca (228 commits)")

---

Tags

adobe-commercemagento2productivity-tools

### Embed Badge

![Health badge](/badges/ctasca-mage-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ctasca-mage-bundle/health.svg)](https://phpackages.com/packages/ctasca-mage-bundle)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
