Skip to content

totallyquiche/hyacinth

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 

Hyacinth

Hyacinth makes it easy to create HTML with PHP using object-oriented programming.

By the way, don't use this!

I created Hyacinth for fun. There are a lot of these types of projects floating around, but writing HTML with PHP is messy and tightly couples the frontend and backend. If this library seems appealing, you may need to reconsider your app's architecture.

Instead, consider using a template system to handle your HTML.

Simple Example

echo (new Hyacinth\Elements\Div)->setAttribute('style', 'font-style: italic;')
                                ->addContent('Hello, World!');
                                
// <div style="font-style: italic;">Hello, World!</div>

Advanced Example

$list = (new Hyacinth\Elements\Ul)->addContentArray([
    (new Hyacinth\Elements\Li)->setAttribute('id', 'first-list-item')->addContent('First'),
    (new Hyacinth\Elements\Li)->setAttribute('id', 'second-list-item')->addContent('Second'),
    (new Hyacinth\Elements\Li)->setAttribute('id', 'third-list-item')->addContent('Third')
]);

echo $list;

// <ul><li id="first-list-item"></li><li id="second-list-item"></li><li id="third-list-item"></li></ul>

echo $list->getContent()[0]->getAttributeValue('id');

// first-list-item

About

Hyacinth makes it easy to create HTML with PHP using object-oriented programming.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages