Generate pure html files based on a PHP file and a mock.
- Folder structure:
.
└── components/
├── card/
│ ├── index.php
│ └── mock.json
└── header/
├── index.php
└── mock.json
- Component card as example:
index.php
<div>
<div><?php echo $title; ?></div>
<ul>
<?php foreach ($items as $item) : ?>
<li><?php echo $item['name']; ?></li>
<li><?php echo $item['age']; ?></li>
<?php endforeach; ?>
</ul>
</div>
mock.json
{
"title": "My card",
"items": [
{
"name": "John Doe",
"age": 24
},
{
"name": "Mary Doe",
"age": 28
}
]
}
- Run
composer require --dev apiki/maristela-cli
on terminal; - Add a new script on composer.json:
"scripts": {
"make:components": "Maristela\\Cli\\App::buildComponents"
}
- Run
composer make:components
on terminal; - Will be generated a
_static
folder inside yourcomponents
folder. - You can override default
components
creating a.maristela-cli.json
on your project and setting a value forcomponentsDir
:
.maristela-cli.json
{
"componentsDir": "components"
}