PHPackages                             takemo101/simple-vm - 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. takemo101/simple-vm

ActiveLibrary[Templating &amp; Views](/categories/templating)

takemo101/simple-vm
===================

Simple ViewModel Object

v0.1.4(4y ago)11.5k1MITPHPPHP ^8.0

Since Feb 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/takemo101/simple-vm)[ Packagist](https://packagist.org/packages/takemo101/simple-vm)[ Docs](https://github.com/takemo101/simple-vm)[ RSS](/packages/takemo101-simple-vm/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (7)Used By (1)

Simple ViewModel Object
=======================

[](#simple-viewmodel-object)

[![Testing](https://github.com/takemo101/simple-vm/actions/workflows/testing.yml/badge.svg)](https://github.com/takemo101/simple-vm/actions/workflows/testing.yml)[![PHPStan](https://github.com/takemo101/simple-vm/actions/workflows/phpstan.yml/badge.svg)](https://github.com/takemo101/simple-vm/actions/workflows/phpstan.yml)[![PHPStan](https://github.com/takemo101/simple-vm/actions/workflows/phpstan.yml/badge.svg)](https://github.com/takemo101/simple-vm/actions/workflows/phpstan.yml)

The Simple VM allows you to simply create a ViewModel object.
By using the ViewModel object, you can convey appropriate data to the View.
Enjoy!

How to use
----------

[](#how-to-use)

Please use as follows

### Basic

[](#basic)

```
use Takemo101\SimpleVM\ViewModel;

/**
 * Create a class that inherits from the ViewModel class
 */
class TestViewModel extends ViewModel
{
    // Set methods and property names that are not reflected in this property
    protected array $__ignores = [
        'd',
    ];

    /**
     * constructor
     *
     * @param string $a
     * @param integer $b
     */
    public function __construct(
        public string $a,
        private int $b,
    ) {
        // public property is reflected in View
    }

    /**
     * public method is reflected in View
     *
     * @return string
     */
    public function c(): string
    {
        return 'C';
    }

    /**
     * @return string
     */
    public function d(): string
    {
        return 'D';
    }

    /**
     * Set the initial value to the __data method
     *
     * @return mixed[]
     */
    public function __data(): array
    {
        return [
            'e' => 'E',
        ];
    }
}

$model = new TestViewModel('A', 2);

var_dump($model->toArray());
// array(3) {
//   'e' =>
//   string(1) "E"
//   'a' =>
//   string(1) "A"
//   'c' =>
//   string(1) "C"
// }
```

### PHP Attribute

[](#php-attribute)

You can use the PHP Attribute class.

```
use Takemo101\SimpleVM\ViewModel;
use Takemo101\SimpleVM\Attribute\{
    Ignore,
    ChangeName,
};

/**
 * Create a class that inherits from the ViewModel class
 */
class TestAttributeViewModel extends ViewModel
{
    /**
     * Not output when Ignore class is set in a property or method
     *
     * @param string $a
     */
    public function __construct(
        #[Ignore]
        public string $a,
    ) {
        // public property is reflected in View
    }

    /**
     * Setting the ChangeName class on a property or method will rename the data
     *
     * @return string
     */
    #[ChangeName('cc')]
    public function c(): string
    {
        return 'C';
    }
}

$model = new TestAttributeViewModel('A');

var_dump($model->toArray());
// array(3) {
//   'cc' =>
//   string(1) "C"
// }
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.6% 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 ~7 days

Total

5

Last Release

1521d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2139dffa0ff324f185e4afd76e1bfad1ff5270c4cf3eabe278dc353ea16aa84e?d=identicon)[takemo101](/maintainers/takemo101)

---

Top Contributors

[![hayama-kei](https://avatars.githubusercontent.com/u/73094141?v=4)](https://github.com/hayama-kei "hayama-kei (14 commits)")[![takemo101](https://avatars.githubusercontent.com/u/66665053?v=4)](https://github.com/takemo101 "takemo101 (8 commits)")

---

Tags

phppackageviewmodel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/takemo101-simple-vm/health.svg)

```
[![Health](https://phpackages.com/badges/takemo101-simple-vm/health.svg)](https://phpackages.com/packages/takemo101-simple-vm)
```

###  Alternatives

[endroid/qr-code-bundle

Endroid QR Code Bundle

32110.6M17](/packages/endroid-qr-code-bundle)

PHPackages © 2026

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