{"id":15077762,"url":"https://github.com/starychfojtu/viewcomponentbundle","last_synced_at":"2026-02-14T21:30:53.140Z","repository":{"id":57059154,"uuid":"94685184","full_name":"starychfojtu/ViewComponentBundle","owner":"starychfojtu","description":"Implementation of View Components for Symfony 3.3","archived":false,"fork":false,"pushed_at":"2017-09-25T07:51:52.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T14:50:08.120Z","etag":null,"topics":["component","components","symfony","symfony-bundle","symfony3","symfony3-bundle","twig","twig-extension","viewcomponent"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/starychfojtu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-18T12:14:53.000Z","updated_at":"2017-06-18T14:40:46.000Z","dependencies_parsed_at":"2022-08-24T14:53:26.329Z","dependency_job_id":null,"html_url":"https://github.com/starychfojtu/ViewComponentBundle","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/starychfojtu/ViewComponentBundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starychfojtu%2FViewComponentBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starychfojtu%2FViewComponentBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starychfojtu%2FViewComponentBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starychfojtu%2FViewComponentBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/starychfojtu","download_url":"https://codeload.github.com/starychfojtu/ViewComponentBundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/starychfojtu%2FViewComponentBundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002401,"owners_count":26083374,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["component","components","symfony","symfony-bundle","symfony3","symfony3-bundle","twig","twig-extension","viewcomponent"],"created_at":"2024-09-25T04:31:54.942Z","updated_at":"2025-10-10T01:45:58.535Z","avatar_url":"https://github.com/starychfojtu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ViewComponentBundle\nImplementation of View Components for Symfony 3.3\n\n# Installation\n\n```\n$ composer require starychfojtu/viewcomponent\n```\n\nSymfony flex might register incorrect namespace in bundles.php. If it did,\ngo ahead and register it yourself with \n```php \n'ViewComponent\\ViewComponentBundle' =\u003e ['all' =\u003e true]\n```\n\n# Configuration\n\n```yaml\nstarychfojtu_view_component:\n    component_dirs: ['AppBundle/Component', 'AppBundle/SpecialComponent'] #results in '/src/AppBundle/Component', '/src/AppBundle/Component/specialComponent'\n    # Specify directories where the bundle should search for components from /src\n    template_dirs: ['components', 'specialComponents'] #results in '/templates/components', '/templates/specialComponents'\n    # Specify directories where the bundle should search for templates from /templates\n```\n\n# Usage\n\nFirst specify your view component by creating a class in configured directories\nand implement ```ViewComponentInterface```. The render method returns associative array of\nobjects that are passed to the view.\n\nYOU HAVE TO NAME YOUR COMPONENT IN THIS WAY : YourSpecialNameViewComponent\nIt is a classic CamelCase naming e.g. MenuViewComponent or CartSummaryViewComponent.\n\n```php\n# src/AppBundle/Component/MenuViewComponent\n\n\u003c?php\n\nnamespace AppBundle\\Component;\n\nuse Starychfojtu\\ViewComponentBundle\\ViewComponentInterface;\n\nclass MenuViewComponent implements ViewComponentInterface\n{\n    public function render(): array\n    {\n        return [\n            'links' =\u003e ['home','about','contact']\n        ];\n    }\n}\n\n```\n\nThen add your template to one of configured directories.\n\n```twig\n# templates/components/Menu.html.twig\n\n{% for link in links %}\n    {{ link }}\n{% endfor %}\n```\n\nAnd finally render your component in the view:\n\n```twig\n{{ component('Menu', 60 * 60) }}\n```\n\nThe second parameter is cache time of the whole component with default set on 0;\n\n## Custom template name\n\nIf you want to specify another template name in view component, just add\na key with template like this:\n\n```php\n# src/AppBundle/Component/MenuViewComponent\n\n\u003c?php\n\nnamespace AppBundle\\SpecialComponent;\n\nuse Starychfojtu\\ViewComponentBundle\\ViewComponentInterface;\n\nclass MenuViewComponent implements ViewComponentInterface\n{\n    public function render(): array\n    {\n        return [\n            'links' =\u003e ['home','about','contact'],\n            'template' =\u003e 'AnotherMenu'\n        ];\n    }\n}\n\n```\n\n## Dependency injection\n\nTo pass any dependencies to the component, just register them as services.\n\nTODO: register them automatically in bundle\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarychfojtu%2Fviewcomponentbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarychfojtu%2Fviewcomponentbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarychfojtu%2Fviewcomponentbundle/lists"}