{"id":20731084,"url":"https://github.com/greg-md/php-view","last_synced_at":"2025-10-26T15:50:52.294Z","repository":{"id":62512568,"uuid":"71001054","full_name":"greg-md/php-view","owner":"greg-md","description":"A powerful View for PHP.","archived":false,"fork":false,"pushed_at":"2019-07-24T07:47:34.000Z","size":123,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T10:21:52.999Z","etag":null,"topics":["blade","greg-md","greg-php","php","php-view","view","viewer","web-artisans"],"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/greg-md.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":"2016-10-15T16:54:59.000Z","updated_at":"2019-07-24T07:47:36.000Z","dependencies_parsed_at":"2022-11-02T13:02:11.430Z","dependency_job_id":null,"html_url":"https://github.com/greg-md/php-view","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/greg-md/php-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-md%2Fphp-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-md%2Fphp-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-md%2Fphp-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-md%2Fphp-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greg-md","download_url":"https://codeload.github.com/greg-md/php-view/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-md%2Fphp-view/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281130765,"owners_count":26448690,"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-26T02:00:06.575Z","response_time":61,"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":["blade","greg-md","greg-php","php","php-view","view","viewer","web-artisans"],"created_at":"2024-11-17T05:13:39.137Z","updated_at":"2025-10-26T15:50:52.259Z","avatar_url":"https://github.com/greg-md.png","language":"PHP","readme":"# Greg PHP View\n\n[![StyleCI](https://styleci.io/repos/71001054/shield?style=flat)](https://styleci.io/repos/71001054)\n[![Build Status](https://travis-ci.org/greg-md/php-view.svg)](https://travis-ci.org/greg-md/php-view)\n[![Total Downloads](https://poser.pugx.org/greg-md/php-view/d/total.svg)](https://packagist.org/packages/greg-md/php-view)\n[![Latest Stable Version](https://poser.pugx.org/greg-md/php-view/v/stable.svg)](https://packagist.org/packages/greg-md/php-view)\n[![Latest Unstable Version](https://poser.pugx.org/greg-md/php-view/v/unstable.svg)](https://packagist.org/packages/greg-md/php-view)\n[![License](https://poser.pugx.org/greg-md/php-view/license.svg)](https://packagist.org/packages/greg-md/php-view)\n\nA powerful View for PHP.\n\n# Table of Contents:\n\n* [Requirements](#requirements)\n* [Compilers](#compilers)\n* [How It Works](#how-it-works)\n* [Documentation](#documentation)\n* [License](#license)\n* [Huuuge Quote](#huuuge-quote)\n\n# Requirements\n\n* PHP Version `^7.1`\n\n# Compilers\n\n- PHP\n- Blade\n\n# How It Works\n\n**First of all**, you have to initialize a [Viewer](docs/Viewer.md):\n\n```php\n$viewsDirectory = __DIR__ . '/views';\n\n$viewer = new \\Greg\\View\\Viewer($viewsDirectory);\n```\n\n**Optionally**, you can add a view compiler. For example a [Blade Compiler](docs/ViewBladeCompiler.md) specially created for the [Viewer](docs/Viewer.md):\n\n```php\n// Turn it to a callable, to load only when using blade templates.\n$viewer-\u003eaddExtension('.blade.php', function () {\n    $compiledViewsDirectory = __DIR__ . '/compiled';\n\n    return new \\Greg\\View\\ViewBladeCompiler($compiledViewsDirectory);\n});\n```\n\n_By default it will use [Renderer](docs/Renderer.md) as an instance of a template._\n\n_Note:_ If you want to use your own compiler, it has to be an instance of [Compiler Strategy](docs/CompilerStrategy.md).\n\n**Now**, you can render views where you want in your application.\n\nCreate a template file in the views directory. For example `welcome.blade.php`:\n\n```blade\n\u003chtml\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eHello, {{ $name }}\u003c/h1\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nUse `welcome` template in your application:\n\n```php\n$content = $viewer-\u003erender('welcome', [\n    'name' =\u003e 'Greg',\n]);\n\necho $content;\n```\n\n# Documentation\n\n* [Viewer](docs/Viewer.md) - The view manager;\n* [Renderer](docs/Renderer.md) - Instance of a template. Could be accessed via `$this` variable in the template.\n* [Loader](docs/Loader.md) - A special loader for [Renderer](docs/Renderer.md) which will give access only to its public properties and methods;\n* [Blade Compiler](docs/BladeCompiler.md) - An independent template compiler;\n* [View Blade Compiler](docs/ViewBladeCompiler.md) - An extended [Blade Compiler](docs/BladeCompiler.md), specially for the [Viewer](Viewer.md).\n* [Compiler Strategy](docs/CompilerStrategy.md) - A strategy for custom compilers;\n* [View Compiler Strategy](docs/ViewCompilerStrategy.md) - A strategy for custom [Viewer](docs/Viewer.md) compilers;\n\n# License\n\nMIT © [Grigorii Duca](http://greg.md)\n\n# Huuuge Quote\n\n![I fear not the man who has practiced 10,000 programming languages once, but I fear the man who has practiced one programming language 10,000 times. #horrorsquad](http://greg.md/huuuge-quote-fb.jpg)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreg-md%2Fphp-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreg-md%2Fphp-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreg-md%2Fphp-view/lists"}