Static Site Generator
With the native Static package, you can generate a static version of any package and serve the files directly.
The site will be generated in the static/{package} folder, then you can configure the web server to use this folder as root directory.
The static package can be modified and improved for specific needs.
Command
bin/magework Static build {package} {baseUrl}
With optional environment variable:
MW_ENVIRONMENT={environment} bin/magework Static build {package} {baseUrl}
If the
baseUrlis missing, pages will use "/" as the base URL and the site can be served on any domain.
All files present at the root of the package's asset folder will be copied to the root of the site (robots.txt, favicon.ico...), except if ignored in the configuration.
Example
For example, if your application contains a package named Acme and you want to serve it at the URL https://www.example.com:
bin/magework Static build Acme https://www.example.com
Configuration
You can create a configuration file in the package to be generated to ignore routes or files.
<?php
// packages/Acme/etc/static.php
$config = [
'static' => [
'ignore_files' => [ // Regex only
'/(.*)README.md$/i',
'/(.*)CHANGELOG.md$/i',
'/(.*)LICENCE$/i',
'/(.*)\.php$/i',
],
'ignore_routes' => [ // Regex only
'/\/secret.html/i',
'/\/secret\/(.*)/i',
],
],
];
- Installation
- Configuration
- Add a new package
- Add a new HTML page
- Templating best practices
- Add a new block
- Assets
- Serve any type of file
- Rewrite a route
- Data assignment
- Objects and class fallback
- Models
- Database
- Forms
- Session messages
- Send emails
- Captcha
- Framework tools
- Console Commands
- Hooks
- Custom shared libraries
- External libraries with composer
- Write content in Markdown
- Static Site Generator