Last week I wrote about how Statie turned from a feature to a burden and why we had to let it go. <br> What will replace it? How do you migrate?
Deprecations without replacements are like nails in the coffin of your forehead while reciting a poem about the beauty of life.
The friendsofphp.org and this blog still uses PHP and is deployed to GitHub pages. How is that possible without Statie?
From Statie, we fluently switch to brand new package - Symfony Static Dumper. A single command that generates HTML and CSS from your Symfony application.
In short, it looks like this:
What I love the most about it, that the Symfony Static Dumper only handles the missing part - generate HTML and CSS. All the rest is up to you, your imagination. You code standard Symfony application, nothing special, nothing weird.
Do you want more advantages?
{{ path('contact') }}
in templates ✅Do you still use Statie? Don't worry; we have a migration path for you.
First, you need to install Symfony packages:
composer require symfony/http-foundation symfony/asset symfony/twig-bridge symfony/twig-bundle symfony/flex symfony/framework-bundle symfony/dotenv doctrine/cache erusev/parsedown-extra
And replace the static generator:
composer remove symplify/statie
composer require symplify/symfony-static-dumper
/source
/templates
robots.txt
or CNAME
to /public
-vendor/bin/statie generate source
+bin/console dump-static-site
Before:
---
layout: "_layouts/default.twig"
title: "Thank You"
id: thank_you
commit_limit: 5
---
<div class="container" id="contact">
<h1>{{ title }}</h1>
<p class="text-center bigger"></p>
</div>
After:
{# templates/thanky_you.twig #}
{% extends "default.twig" %}
{% block content %}
<div class="container" id="contact">
<h1>{{ title }}</h1>
<p class="text-center bigger"></p>
</div>
{% endblock %}
// src/Controller/ThankYouController.php
namespace YourWebsite\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class ThankYouController extends AbstractController
{
/**
* @Route(path="thank-you", name="thank_you")
*/
public function __invoke(): Response
{
return $this->render('thank_you.twig', [
'title' => 'Thank You',
'id' => 'thank_you',
'commit_limit' => 5,
]);
}
}
If you need more inspiration, look at these pull-requests:
All the essential information is in README.
Install the package via composer:
composer require symplify/symfony-static-dumper
Register services - no Flex, no bundles, just simple config:
# config/services.yaml
imports:
- { resource: '../vendor/symplify/symfony-static-dumper/config/config.yaml' }
And dump static website to /output
directory:
bin/console dump-static-website
To see the website, just run the local server:
php -S localhost:8001 -t output
That's it!
Happy coding!
Do you learn from my contents or use open-souce packages like Rector every day?
Consider supporting it on GitHub Sponsors.
I'd really appreciate it!