Developed with love by KnpLabs Hire us for your project!
22

last

by franzwilding

Zero Configuration, Static Site Generator for any Symfony project.

Last – static site generator for any Symfony project

Build Status
Test Coverage

Last is a minimalistic static site generator for Symfony 4 applications. Once installed, Last provides a
command that will simply create requests for all of your routes and dumps the result as a static file to a dist folder.

Installation

(A symfony/flex recipe will be created soon. )

composer require fw/last-bundle

Last should get registered automatically to config/bundles.php. If not, add it by hand:

...
Fw\LastBundle\FwLastBundle::class => ['all' => true],

Usage

Now you can run the dump command and your Symfony app gets exported as static html files.

# will dump to the configured dist folder, defaults to %project%/dist
bin/console last:dump 

# wil dump to the given folder
bin/console last:dump --dist=./custom_dist_folder

Is it production ready?

Soon, however the following is missing yet:

  • [ ] Test with more real life projects
  • [ ] Provide an symfony/flex recipe
  • [ ] Automatically copy assets from public/build, public/bundles/* and other locations to dist folder after dumping

Configuration

fw_last:
    dist_folder: '%kernel.project_dir%/dist' # this is the default dist folder, if you don't set it 
    providers:
        static: true # Static provider is enabled per default, you can disable it here

Request providers

Last runs requests against your kernel. So in order to make it work, all desired requests must be defined. To make
things more easy, Last comes with a request provider for all static routes (routes without mandatory placeholders). So
you only need to implement a custom request provider if you want to include dynamic routes like blog/article/{id}. A
simple provider could look like this:

use Fw\LastBundle\Router\RouteProvider;

class YourustomProvider implements RouteProvider
{
    /**
     * {@inheritdoc}
     */
    public function getRoutes(): array
    {
        return [
            Request::create('blog/article/1'),
            Request::create('blog/article/2'),
            Request::create('blog/article/3'),
        ];
    }
} 

And needs to be a tagged service, in order to make it visible for Last.

Your\CustomBundle\Provider\CustomProvider:
        tags: ['fw.last.route_provider']

Of course you can inject any dependencies like an entity manager to create more advanced providers.

Troubleshooting

My links start with http://localhost/ what should I do?

Use {{ path() }} instead of {{ url() }} in your templates to make your urls relative.

fw_last:
dist_folder: ~
providers:
static: ~
  • feature: Allow to pass force-override option to command to ignore override warnings
    By franzwilding, 2 months ago
  • fix race condition on slow tests
    By franzwilding, 2 months ago
  • feature: Ask the user before overriding an existing folder in dump command.
    By franzwilding, 2 months ago
  • Update README.md
    By web-flow, 2 months ago
  • fix: Transform folder paths to folder/index.* paths
    By franzwilding, 2 months ago
  • Update README.md
    By web-flow, 2 months ago
  • Update README.md
    By web-flow, 2 months ago
  • Add Readme with main documentation
    By franzwilding, 2 months ago
  • feature: Implement actual dump command
    By franzwilding, 2 months ago
  • feature: Implement default provider for all routes without (mendatory) placeholders.
    By franzwilding, 2 months ago
  • Add route manager, that holds all registered route provders
    By franzwilding, 2 months ago
  • fix: travis config
    By franzwilding, 2 months ago
  • Add travis and codeclimate integration
    By franzwilding, 2 months ago
  • feature: Add dist_folder config, finish SiteGeneratorTest
    By franzwilding, 2 months ago
  • feature: create file suffix url generator draft
    By franzwilding, 2 months ago
  • feature: Start implementing site generator service
    By franzwilding, 3 months ago
  • feature [Tests]: Cleanup default config for test usage
    By franzwilding, 3 months ago
  • gitignore composer.lock
    By franzwilding, 3 months ago
  • Remove composer.lock from repo
    By franzwilding, 3 months ago
  • Revert "Revert "Initial commit""
    By franzwilding, 3 months ago
  • Revert "Initial commit"
    By franzwilding, 3 months ago
  • Initial commit
    By franzwilding, 3 months ago