{"id":14966419,"url":"https://github.com/yiisoft/widget","last_synced_at":"2025-09-02T12:32:47.714Z","repository":{"id":37088509,"uuid":"233032763","full_name":"yiisoft/widget","owner":"yiisoft","description":"Widgets are reusable building blocks used to create complex and configurable user interface elements in an object-oriented fashion","archived":false,"fork":false,"pushed_at":"2024-07-02T14:36:30.000Z","size":178,"stargazers_count":25,"open_issues_count":3,"forks_count":7,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-29T14:35:39.981Z","etag":null,"topics":["hacktoberfest","view","widget","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2020-01-10T11:26:12.000Z","updated_at":"2024-07-02T14:36:32.000Z","dependencies_parsed_at":"2024-11-05T16:54:19.030Z","dependency_job_id":null,"html_url":"https://github.com/yiisoft/widget","commit_stats":{"total_commits":132,"total_committers":17,"mean_commits":7.764705882352941,"dds":0.7045454545454546,"last_synced_commit":"1ffdde3bcd8b53162bdfc8d5cbcfbbedbf096315"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":"yiisoft/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fwidget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fwidget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fwidget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fwidget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/widget/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231785208,"owners_count":18426288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","view","widget","yii3"],"created_at":"2024-09-24T13:36:21.430Z","updated_at":"2025-09-02T12:32:47.695Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Widget\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/widget/v)](https://packagist.org/packages/yiisoft/widget)\n[![Total Downloads](https://poser.pugx.org/yiisoft/widget/downloads)](https://packagist.org/packages/yiisoft/widget)\n[![Build status](https://github.com/yiisoft/widget/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/widget/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/widget/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/widget)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fwidget%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/widget/master)\n[![static analysis](https://github.com/yiisoft/widget/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/widget/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/widget/coverage.svg)](https://shepherd.dev/github/yiisoft/widget)\n\nWidgets are reusable building blocks used to create complex and configurable\nuser interface elements in an object-oriented fashion.\n\nThis package provides an abstract class and a factory for creating widgets,\nready-made widgets are provided in the [yiisoft/yii-widgets](https://github.com/yiisoft/yii-widgets) package.\n\n## Requirements\n\n- PHP 8.0 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n\n```shell\ncomposer require yiisoft/widget\n```\n\n## General usage\n\nIn order to implement your own widget, you need to create a class that extends the abstract class\n`Yiisoft\\Widget\\Widget`. In most cases it is enough to implement `render()` method.\n\n```php\nfinal class MyWidget extends \\Yiisoft\\Widget\\Widget\n{\n    public function render(): string\n    {\n        return 'My first widget.'.\n    }\n}\n```\n\nTo get the string \"My first widget.\" in the view, call the `widget()` method. Inside which the\n`Yiisoft\\Widget\\WidgetFactory` will create an instance of the `MyWidget`, and when converting the object\nto a string, the declared `render()` method will be called.\n\n```php\n\u003c?= MyWidget::widget() ?\u003e\n```\n\nThe `Yiisoft\\Widget\\WidgetFactory` factory uses a [Factory](https://github.com/yiisoft/factory)\ninstance to create widget objects, so you can require dependencies by listing them in your widget's constructor\nand set default values when initializing the factory. To initialize the widget factory call\n`WidgetFactory::initialize()` once before using widgets:\n\n```php\n/**\n * @var \\Psr\\Container\\ContainerInterface $container\n */\n \n$widgetDefaults = [\n    MyWidget::class =\u003e [\n        'withNumber()' =\u003e [42],\n    ],\n];\n\n\\Yiisoft\\Widget\\WidgetFactory::initialize($container, $widgetDefaults);\n```\n\nIt is a good idea to do that for the whole application. See Yii example in the configuration file of this package\n[`config/bootstrap.php`](https://github.com/yiisoft/widget/blob/master/config/bootstrap.php).\n\n## Documentation\n\n- Guide: [English](docs/guide/en/README.md), [Português - Brasil](docs/guide/pt-BR/README.md)\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Widget is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fwidget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fwidget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fwidget/lists"}