Giter VIP home page Giter VIP logo

last's Introduction

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.

last's People

Contributors

franzwilding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

last's Issues

Missing encore_entry_link_tags and encore_entry_script_tags in $response->getContent()

I noticed that in SiteGenerator service method generate(array $requests, string $dist_folder) when symfony/webpack-encore-bundle is enabled only for the first handled request the $response->getContent() contains the generated {{ encore_entry_link_tags('app') }} and {{ encore_entry_script_tags('app') }} content.

Es.
Suppose we have 10 declared route in a custom route provider, like https://github.com/franzwilding/last#request-providers
For the first request the two above mentioned twig tags are present in $response->getContent();

In the other 9 responses encore entries were not rendered.

It's a router cache issue?

Symfony 5, 6 support

In a Symfony 6.1 application:

$ composer require fw/last-bundle
...
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires fw/last-bundle ^1.1 -> satisfiable by fw/last-bundle[v1.1].
    - fw/last-bundle v1.1 requires symfony/framework-bundle ^4.1 -> found symfony/framework-bundle[v4.1.0, ..., v4.4.42] but the package is fixed to v6.1.1 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.