{"id":21771123,"url":"https://github.com/initphp/views","last_synced_at":"2026-05-19T05:39:56.944Z","repository":{"id":65233458,"uuid":"588836720","full_name":"InitPHP/Views","owner":"InitPHP","description":"InitPHP Views","archived":false,"fork":false,"pushed_at":"2023-01-14T07:31:44.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-26T03:13:44.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/InitPHP.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}},"created_at":"2023-01-14T07:08:03.000Z","updated_at":"2023-01-14T07:08:43.000Z","dependencies_parsed_at":"2023-01-15T18:30:20.601Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Views","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FViews","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FViews/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FViews/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FViews/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Views/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244746790,"owners_count":20503264,"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":[],"created_at":"2024-11-26T14:15:09.478Z","updated_at":"2025-10-12T18:13:25.583Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InitPHP Views\r\n\r\n\r\n### Installation\r\n\r\n```\r\ncomposer require initphp/views\r\n```\r\n\r\n### Usage\r\n\r\n_**Note :** Remember to choose to work with an adapter before using it._\r\n\r\n```php\r\n$data = [\r\n    'username'  =\u003e 'admin'\r\n];\r\n\r\necho view('dashboard/dashboard', $data);\r\n```\r\n\r\nGive a string array to load multiple views.\r\n\r\n```php\r\n$data = [\r\n    'username'  =\u003e 'admin'\r\n];\r\n\r\necho view(['header', 'content', 'footer'], $data);\r\n```\r\n\r\n`$data` can be an associative array or an object.\r\n\r\n```php\r\n$data = new stdClass;\r\n$data-\u003eusername = 'admin';\r\n\r\necho view('dashboard/profile', $data);\r\n```\r\n\r\n## Adapters\r\n\r\n### PurePHP Adapter\r\n\r\n```php\r\nuse \\InitPHP\\Views\\Facade\\View;\r\nuse \\InitPHP\\Views\\Adapters\\PurePHPAdapter;\r\n\r\n$viewAdapter = new PurePHPAdapter(__DIR__ . '/Views/');\r\n\r\nView::via($viewAdapter);\r\n```\r\n\r\n__Note :__ This adapter uses `.php` for the extension of the view files. If the view file does not end with `.php` it is added automatically.\r\n\r\n__Note :__ This adapter includes the view files as a PHP file at runtime.\r\n\r\n### Laravel Blade (Illuminate/View) Adapter\r\n\r\nDon't forget to install the relevant packages before you start.\r\n\r\n```\r\ncomposer require illuminate/view\r\n```\r\n\r\nTo start using the adapter, just generate the Instance of the relevant adapter.\r\n\r\n```php\r\nuse \\InitPHP\\Views\\Facade\\View;\r\nuse \\InitPHP\\Views\\Adapters\\BladeAdapter;\r\n\r\n$viewAdapter = new BladeAdapter(__DIR__ . '/Views/', __DIR__ . '/Cache/');\r\n\r\nView::via($viewAdapter);\r\n```\r\n\r\n__Note :__ This adapter may have some unique changes. [Docs](https://laravel.com/docs/9.x/blade)\r\n\r\n```php\r\nView::directive('now', function ($format = null) {\r\n    return '\u003c?php echo '\r\n            . ($format === null ? 'date(\"Y-m-d H:i:s\")' : 'date(' . $format . ')')\r\n            . ' ?\u003e';\r\n});\r\n\r\n// @now\r\n// @now(\"Y-m-d\")\r\n```\r\n\r\n### Symfony Twig (Twig/Twig) Adapter\r\n\r\nDon't forget to install the relevant packages before you start.\r\n\r\n```\r\ncomposer require twig/twig\r\n```\r\n\r\nTo start using the adapter, just generate the Instance of the relevant adapter.\r\n\r\n```php\r\nuse \\InitPHP\\Views\\Facade\\View;\r\nuse \\InitPHP\\Views\\Adapters\\TwigAdapter;\r\n\r\n$viewAdapter = new TwigAdapter(__DIR__ . '/Views/', __DIR__ . '/Cache/');\r\n\r\nView::via($viewAdapter);\r\n```\r\n\r\n__Note :__ Note that the Twig engine accepts any file extension and you have to specify it manually. [Docs](https://twig.symfony.com/doc/3.x/templates.html)\r\n\r\n```php\r\n$data = [\r\n    'username'  =\u003e 'admin'\r\n];\r\n\r\necho view('dashboard/dashboard.html', $data);\r\n```\r\n\r\n## Credits\r\n\r\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) \u003c\u003cinfo@muhammetsafak.com.tr\u003e\u003e\r\n\r\n## License\r\n\r\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fviews","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Fviews","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fviews/lists"}