PHPackages                             virusecks/objectron - 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. virusecks/objectron

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

virusecks/objectron
===================

Object creator from template

0.0.4-alpha(8y ago)217MITPHPPHP &gt;=7.0

Since Apr 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/VirusEcks/objectron)[ Packagist](https://packagist.org/packages/virusecks/objectron)[ RSS](/packages/virusecks-objectron/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (5)Used By (0)

Objectron
=========

[](#objectron)

> Objectron uses string template to return a designed class.

instead of using 30 different model to modify data before using it in your project use 1 base model with different string (template) to modify the output

Installation
------------

[](#installation)

Composer:

```
VirusEcks/Objectron
```

Usage example
-------------

[](#usage-example)

```
$arr[] = ['id'=> 1, 'name'=>'john', 'class'=>10];
$arr[] = ['id'=> 5, 'name'=>'clam', 'class'=>4];
$arr[] = ['id'=> 8, 'name'=>'robot', 'class'=>1];

$result1 = Objectron::toObject($arr, 'id', '%id%, Student Class=%class%, Student Name => %name% ,Student group=>%id%');
$result2 = Objectron::toObject($arr, 'name', '%id%, %class%, %name%');
$result3 = Objectron::toObject($arr, 'id', '%name%');
$result4 = Objectron::toObject($arr, 'id');
$result5 = Objectron::toObject($arr);

print_r($result1);
print_r($result2);
print_r($result3);
print_r($result4);
print_r($result5);

$result1 =
            stdClass Object
            (
                [1] => stdClass Object
                    (
                        [0] => 1
                        [Student Class] => 10
                        [Student Name] => john
                        [Student group] => 1
                    )

                [5] => stdClass Object
                    (
                        [0] => 5
                        [Student Class] => 4
                        [Student Name] => clam
                        [Student group] => 5
                    )

                [8] => stdClass Object
                    (
                        [0] => 8
                        [Student Class] => 1
                        [Student Name] => robot
                        [Student group] => 8
                    )

            )

$result2 =
            stdClass Object
            (
                [john] => stdClass Object
                    (
                        [0] => 1
                        [1] => 10
                        [2] => john
                    )

                [clam] => stdClass Object
                    (
                        [0] => 5
                        [1] => 4
                        [2] => clam
                    )

                [robot] => stdClass Object
                    (
                        [0] => 8
                        [1] => 1
                        [2] => robot
                    )

            )

$result3 =
            stdClass Object
            (
                [1] => john
                [5] => clam
                [8] => robot
            )

$result4 =
            stdClass Object
            (
                [1] => Array
                    (
                        [id] => 1
                        [name] => john
                        [class] => 10
                    )

                [5] => Array
                    (
                        [id] => 5
                        [name] => clam
                        [class] => 4
                    )

                [8] => Array
                    (
                        [id] => 8
                        [name] => robot
                        [class] => 1
                    )

            )

$result5 =
            stdClass Object
            (
                [0] => Array
                    (
                        [id] => 1
                        [name] => john
                        [class] => 10
                    )

                [1] => Array
                    (
                        [id] => 5
                        [name] => clam
                        [class] => 4
                    )

                [2] => Array
                    (
                        [id] => 8
                        [name] => robot
                        [class] => 1
                    )

            )
```

*For more examples and usage, please refer to the [Wiki](https://github.com/virusecks/objectron/wiki).*

Development
-----------

[](#development)

This project was made as Proof of Work for some certain Person who thinks that it's useless and undoable and if it was done it would be totally slow.

this was made in 1 day during my free time so it might need lots of modifications and testing, i'll be using it in a project so that would be good testing ground for it.

Release History
---------------

[](#release-history)

- 0.0.4-alpha
    - added option to use tokenizer

    - changed the call style to static function
    - FASTER performance -&gt; 260% faster performance on same data and formatting from last version

    - added some generic tests (no unit test yet)
    - added better property value finder (can be used outside of project)

    - removed some of the unneeded code

    - changed the regex to perform better on nonuniform formatting
- 0.0.3-alpha
    - changed the layout and namespace
- 0.0.2-alpha
    - Added some adjustments and fixes
- 0.0.1-alpha
    - Initial release and WIP

Meta
----

[](#meta)

Ahmed Salah – [@virusecks](https://twitter.com/virusecks) –

Distributed under the MIT license. See `LICENSE` for more information.

Contributing
------------

[](#contributing)

1. Fork it ()
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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 ~5 days

Total

4

Last Release

2936d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/293d01a4007c5d924b57a96b79fb6b44e257cc8e4d6bcec6e5569fbcc817a2f8?d=identicon)[VirusEcks](/maintainers/VirusEcks)

---

Top Contributors

[![VirusEcks](https://avatars.githubusercontent.com/u/3261210?v=4)](https://github.com/VirusEcks "VirusEcks (11 commits)")

---

Tags

arrayclassformatterobjectphptokenizerarrayobjecttemplatestdclass

### Embed Badge

![Health badge](/badges/virusecks-objectron/health.svg)

```
[![Health](https://phpackages.com/badges/virusecks-objectron/health.svg)](https://phpackages.com/packages/virusecks-objectron)
```

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.5k34.7M186](/packages/phpoffice-phpword)[rize/uri-template

PHP URI Template (RFC 6570) supports both expansion &amp; extraction

420137.3M46](/packages/rize-uri-template)[mopa/bootstrap-sandbox-bundle

Seperate live docs from code

256.8k](/packages/mopa-bootstrap-sandbox-bundle)[larablocks/pigeon

A more flexible email message builder for Laravel 5 including chained methods, reusable message configurations, and message layout and template view management.

143.7k](/packages/larablocks-pigeon)

PHPackages © 2026

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