Typed template system

0.3.0 2022-12-26 13:11 UTC

This package is auto-updated.

Last update: 2023-08-26 14:50:59 UTC


🔔 Subscribe to the newsletter to don't miss any update regarding Chevere.


Build Code size Apache-2.0 PHPStan Mutation testing badge

Quality Gate Status Maintainability Rating Reliability Rating Security Rating Coverage Technical Debt CodeFactor Codacy Badge


What is Danky?

Danky is a typed template system for PHP. Contrary to all other template systems, in Danky templates are classes.

🦄 Templates explicit declare its scope on construct, the $render property can be of type string or Template.

<?php // Quote.php

use Chevere\Danky\Template;

class Quote extends Template
    public function __construct(string $text, string $author) {
        $this->render =
            <quote>"$text" --$author</quote>

That <<<HTML ... is Heredoc syntax string literal. In Danky, you use all the stuff that has been always there to handle multi-line string literals. Heredoc is great for templates as it evaluates variables, making templates clean to read.

<?php // Home.php

use Chevere\Danky\Template;

class Home extends Template
    public function __construct(Template $content) {
        $this->render =

Template classes implements Stringable, you can use any template object within string literals.

<?php // index.php

use function Chevere\Danky\import;
use Home;
use Quote;

    new Home(
        content: new Quote(
            text: 'Hello, world!',
            author: 'Rodolfo'

🥳 Congratulations! You just mastered Danky.

    <quote>"Hello, world!"</quote>

Now run php demo/index.php for a more complete example.


Copyright 2022 Rodolfo Berrios A.

Chevere is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.