{"id":18637990,"url":"https://github.com/imponeer/smarty-foreachq","last_synced_at":"2026-01-04T07:15:49.651Z","repository":{"id":38012013,"uuid":"335385699","full_name":"imponeer/smarty-foreachq","owner":"imponeer","description":"Rewritten @smarty-php foreach variant that was invented for use in @xoops, but nowadays is used in some other PHP based CMS'es (like @ImpressCMS!)","archived":false,"fork":false,"pushed_at":"2024-08-01T11:05:30.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-01T15:27:27.704Z","etag":null,"topics":["foreach","hacktoberfest","smarty","smarty-plugins"],"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/imponeer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2021-02-02T18:30:15.000Z","updated_at":"2024-08-01T11:05:33.000Z","dependencies_parsed_at":"2024-05-01T12:54:39.876Z","dependency_job_id":"587142b8-8516-4b9c-8946-e5864dd2e447","html_url":"https://github.com/imponeer/smarty-foreachq","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":"0.38095238095238093","last_synced_commit":"452c031f423ea75008f11c0ea3474fb527f2eafc"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-foreachq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-foreachq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-foreachq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-foreachq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imponeer","download_url":"https://codeload.github.com/imponeer/smarty-foreachq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223466133,"owners_count":17149768,"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":["foreach","hacktoberfest","smarty","smarty-plugins"],"created_at":"2024-11-07T05:38:33.712Z","updated_at":"2026-01-04T07:15:49.646Z","avatar_url":"https://github.com/imponeer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/github/license/imponeer/smarty-foreachq.svg)](LICENSE) [![GitHub release](https://img.shields.io/github/release/imponeer/smarty-foreachq.svg)](https://github.com/imponeer/smarty-foreachq/releases) [![PHP](https://img.shields.io/packagist/php-v/imponeer/smarty-foreachq.svg)](http://php.net) [![Packagist](https://img.shields.io/packagist/dm/imponeer/smarty-foreachq.svg)](https://packagist.org/packages/imponeer/smarty-foreachq) [![Smarty version requirement](https://img.shields.io/packagist/dependency-v/imponeer/smarty-foreachq/smarty%2Fsmarty)](https://smarty-php.github.io)\n\n# Smarty ForeachQ\n\n\u003e Backward compatibility foreach implementation for legacy XOOPS and ImpressCMS templates\n\nRewritten (due that original use [GPLv2+](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) license) [Smarty](https://smarty.net) foreach variant that was invented for use in [XOOPS](https://xoops.org), but nowadays used in some other PHP based CMS'es (like [ImpressCMS](https://impresscms.org)!).\n\nSee, [original version of this smarty plugin in Xoops](https://github.com/XOOPS/XoopsCore25/blob/v2.5.8/htdocs/class/smarty/xoops_plugins/compiler.foreachq.php) to see more accurate description why this plugin exists.\n\n## Installation\n\nTo install and use this package, we recommend to use [Composer](https://getcomposer.org):\n\n```bash\ncomposer require imponeer/smarty-foreachq\n```\n\nOtherwise, you need to include manually files from `src/` directory.\n\n## Setup\n\n### Basic Setup\n\nTo register the ForeachQ extension with Smarty, add the extension class to your Smarty instance:\n\n```php\n// Create a Smarty instance\n$smarty = new \\Smarty\\Smarty();\n\n// Register the ForeachQ extension\n$smarty-\u003eaddExtension(new \\Imponeer\\Smarty\\Extensions\\ForeachQ\\ForeachQExtension());\n```\n\n### Using with Symfony Container\n\nTo integrate with Symfony, you can leverage autowiring, which is the recommended approach for modern Symfony applications:\n\n```yaml\n# config/services.yaml\nservices:\n    # Enable autowiring and autoconfiguration\n    _defaults:\n        autowire: true\n        autoconfigure: true\n\n    # Register your application's services\n    App\\:\n        resource: '../src/*'\n        exclude: '../src/{DependencyInjection,Entity,Tests,Kernel.php}'\n\n    # Configure Smarty with the extension\n    # The ForeachQExtension will be autowired automatically\n    \\Smarty\\Smarty:\n        calls:\n            - [addExtension, ['@Imponeer\\Smarty\\Extensions\\ForeachQ\\ForeachQExtension']]\n```\n\nThen in your application code, you can simply retrieve the pre-configured Smarty instance:\n\n```php\n// Get the Smarty instance with the ForeachQ extension already added\n$smarty = $container-\u003eget(\\Smarty\\Smarty::class);\n```\n\n### Using with PHP-DI\n\nWith PHP-DI container, you can take advantage of autowiring for a very simple configuration:\n\n```php\nuse function DI\\create;\nuse function DI\\get;\n\nreturn [\n    // Configure Smarty with the extension\n    \\Smarty\\Smarty::class =\u003e create()\n        -\u003emethod('addExtension', get(\\Imponeer\\Smarty\\Extensions\\ForeachQ\\ForeachQExtension::class))\n];\n```\n\nThen in your application code, you can retrieve the Smarty instance:\n\n```php\n// Get the configured Smarty instance\n$smarty = $container-\u003eget(\\Smarty\\Smarty::class);\n```\n\n### Using with League Container\n\nIf you're using League Container, you can register the extension like this:\n\n```php\n// Create the container\n$container = new \\League\\Container\\Container();\n\n// Register Smarty with the ForeachQ extension\n$container-\u003eadd(\\Smarty\\Smarty::class, function() {\n    $smarty = new \\Smarty\\Smarty();\n\n    // Configure Smarty...\n\n    // Create and add the ForeachQ extension\n    $extension = new \\Imponeer\\Smarty\\Extensions\\ForeachQ\\ForeachQExtension();\n    $smarty-\u003eaddExtension($extension);\n\n    return $smarty;\n});\n```\n\nThen in your application code, you can retrieve the Smarty instance:\n\n```php\n// Get the configured Smarty instance\n$smarty = $container-\u003eget(\\Smarty\\Smarty::class);\n```\n\n## Usage\n\n**Simple iteration:**\n```smarty\n{foreachq from=$users item=user}\n    \u003cp\u003eUser: {$user.name}\u003c/p\u003e\n{/foreachq}\n```\n\n**With key and item:**\n```smarty\n{foreachq from=$data key=index item=value}\n    \u003cp\u003e{$index}: {$value}\u003c/p\u003e\n{/foreachq}\n```\n\n**Nested loops:**\n```smarty\n{foreachq from=$categories item=category}\n    \u003ch2\u003e{$category.name}\u003c/h2\u003e\n    {foreachq from=$category.items item=item}\n        \u003cp\u003e- {$item.title}\u003c/p\u003e\n    {/foreachq}\n{/foreachq}\n```\n\n## Development\n\n### Code Quality Tools\n\nThis project uses several tools to ensure code quality:\n\n- **PHPUnit** - For unit testing\n```bash\ncomposer test\n```\n\n- **PHP CodeSniffer** - For coding standards (PSR-12)\n```bash\ncomposer phpcs    # Check code style\ncomposer phpcbf   # Fix code style issues automatically\n```\n\n- **PHPStan** - For static analysis\n```bash\ncomposer phpstan\n```\n\n## Documentation\n\nAPI documentation is automatically generated and available in the project's wiki. For more detailed information about the classes and methods, please refer to the [project wiki](https://github.com/imponeer/smarty-foreachq/wiki).\n\n## Contributing\n\nContributions are welcome! Here's how you can contribute:\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature-name`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin feature-name`\n5. Submit a pull request\n\nPlease make sure your code follows the PSR-12 coding standard and include tests for any new features or bug fixes.\n\nIf you find a bug or have a feature request, please create an issue in the [issue tracker](https://github.com/imponeer/smarty-foreachq/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimponeer%2Fsmarty-foreachq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimponeer%2Fsmarty-foreachq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimponeer%2Fsmarty-foreachq/lists"}