spatie / server-side-rendering

Server side rendering JavaScript in a PHP application
https://sebastiandedeyne.com/posts/2018/server-side-rendering-javascript-from-php
MIT License
602 stars 34 forks source link

Remove resolver and don't handle client scripts anymore #9

Closed sebastiandedeyne closed 6 years ago

sebastiandedeyne commented 6 years ago

This PR removes everything regarding the Resolver and client script tag rendering. They both added assumptions, magic and complexity to the code base, so I think we're better off without them.

Most importantly, resolvers are hard to explain. While they rendering an app in a view a bit less verbose, they made it harder to get started with this package.

Now the package user is in charge of adding their own script tag, and that's pretty much the only noticeable change.

If you wan't to add something dynamic to your resolves, you can pass a simple callback to resolveEntryWith.

echo $renderer
    ->resolveEntryWith(function (string $entry): string {
        return __DIR__."/../../public/js/{$entry}-server.js";
    })
    ->entry('app')
    ->render();

Some public methods have been renamed too: