{"id":15058548,"url":"https://github.com/enflow/livewire-twig","last_synced_at":"2025-04-10T05:11:12.814Z","repository":{"id":44317785,"uuid":"299701926","full_name":"enflow/livewire-twig","owner":"enflow","description":"Add Livewire components in your Twig templates","archived":false,"fork":false,"pushed_at":"2024-03-15T12:28:41.000Z","size":61,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-16T13:36:28.892Z","etag":null,"topics":["livewire","twig"],"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/enflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"custom":"https://enflow.nl/contact"}},"created_at":"2020-09-29T18:17:52.000Z","updated_at":"2024-04-15T13:59:36.906Z","dependencies_parsed_at":"2024-01-01T13:29:57.783Z","dependency_job_id":"8a5a9592-602b-4e06-be4c-a7ad40aa1c2a","html_url":"https://github.com/enflow/livewire-twig","commit_stats":{"total_commits":20,"total_committers":4,"mean_commits":5.0,"dds":0.4,"last_synced_commit":"1909911f8762fea11227a0ad53ff6bed883175e2"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Flivewire-twig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Flivewire-twig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Flivewire-twig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enflow%2Flivewire-twig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enflow","download_url":"https://codeload.github.com/enflow/livewire-twig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161276,"owners_count":21057555,"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":["livewire","twig"],"created_at":"2024-09-24T22:25:00.726Z","updated_at":"2025-04-10T05:11:12.788Z","avatar_url":"https://github.com/enflow.png","language":"PHP","readme":"# Livewire for Twig\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/enflow/livewire-twig.svg?style=flat-square)](https://packagist.org/packages/enflow/livewire-twig)\n![GitHub Workflow Status](https://github.com/enflow/livewire-twig/workflows/run-tests/badge.svg)\n[![Total Downloads](https://img.shields.io/packagist/dt/enflow/livewire-twig.svg?style=flat-square)](https://packagist.org/packages/enflow/livewire-twig)\n\nThe `enflow/livewire-twig` package provides the option to load Livewire components in your Twig templates.\n\n## Versions\n\n### \u003c= 3.x.x\nVersion 3.x.x supports Livewire 2.\n\n### \u003e= 4.x.x\nVersion 4.xxx supports Livewire 3.\n\nThis version changes from the `{% livewire.component test %}` syntax to the `{% livewire.component 'test' %}` syntax.\n\nThe name argument for {% livewire.component %} and the other directives is now interpreted as an expression, allowing the use of variables or Twig expressions as a name. Note that for this reason a constant name now must be enclosed in quotes.\n\n## Installation\nYou can install the package via composer:\n\n``` bash\ncomposer require enflow/livewire-twig\n```\n\n## Usage\nThe Twig extension will automatically register when `rcrowe/twigbridge` is used.\nIf you're using another configuration, you may wish to register the extension manually by loading the extension `Enflow\\LivewireTwig\\LivewireExtension`.\n\nThis package provides wrappers for the `@livewireScripts`, `@livewireStyles`, `@livewireScriptConfig`, `@livewire`, `@entangle`, `@this` and `@persist`,  directives. Everything else under the hood is powered by `livewire/livewire`.   \nYou can register your Livewire components like normal. \n\nTo use Livewire, add the following tags in the `head` tag, and before the end `body` tag in your template.\n\n```twig\n\u003chtml\u003e\n\u003chead\u003e\n    ...\n    {{ livewireStyles() }}\n\u003c/head\u003e\n\u003cbody\u003e\n    ...\n    {{ livewireScripts() }}\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nIn your body you may include the component like:\n\n```twig\n{# The Twig version of '@livewire' #}\n{% livewire.component 'counter' %}\n\n{# If you wish to pass along variables to your component #}\n{% livewire.component 'counter' with {'count': 3} %}\n\n{# To include a nested component (or dashes), you need to use '' #}\n{% livewire.component 'nested.component' %}\n\n{# To use key tracking, you need to use key(\u003cexpression\u003e) #}\n{% livewire.component 'counter' key('counterkey') %}\n\n{# The Twig version of '@persist' #}\n{% livewire.persist 'name' %}\n\u003cdiv\u003e\n    ...\n\u003c/div\u003e\n{% livewire.endpersist %}\n\n{# The Twig version of '@entangle' (as of Livewire 3.01 poorly documented, need to check the source code) #}\n{% livewire.entangle 'expression' %}\n\n{# The Twig version of '@this' (Can only be used after Livewire initialization is complete) #}\n{% livewire.this %}\n\n{# The Twig version of '@livewireScriptConfig' (as of Livewire 3.01 poorly documented, need to check the source code) #}\n{{ livewireScriptConfig(\u003coptions\u003e) }}\n```\n\n### Example\n\nAdd the following to `resources/views/livewire/counter.twig`\n```twig\n\u003cdiv\u003e\n    \u003cdiv wire:click=\"add\"\u003e+\u003c/div\u003e\n    \u003cdiv\u003e{{ count }}\u003c/div\u003e\n    \u003cdiv wire:click=\"subtract\"\u003e-\u003c/div\u003e\n\u003c/div\u003e\n```\n\nAdd the following to `app/Http/Livewire/Counter.php`\n```php\n\u003c?php\n\nnamespace App\\Http\\Livewire;\n\nuse Livewire\\Component;\n\nclass Counter extends Component\n{\n    public int $count = 1;\n\n    public function add()\n    {\n        $this-\u003ecount++;\n    }\n\n    public function subtract()\n    {\n        $this-\u003ecount--;\n    }\n}\n```\n\n## Todo\n- [ ] Moar tests.\n\n## Testing\n``` bash\n$ composer test\n```\n\n## Contributing\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\nIf you discover any security related issues, please email michel@enflow.nl instead of using the issue tracker.\n\n## Credits\n- [Michel Bardelmeijer](https://github.com/mbardelmeijer)\n- [All Contributors](../../contributors)\n\n## About Enflow\nEnflow is a digital creative agency based in Alphen aan den Rijn, Netherlands. We specialize in developing web applications, mobile applications and websites. You can find more info [on our website](https://enflow.nl/en).\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":["https://enflow.nl/contact"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenflow%2Flivewire-twig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenflow%2Flivewire-twig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenflow%2Flivewire-twig/lists"}