Download the PHP package clarkwinkelmann/flarum-mithril2html without Composer

On this page you can find all versions of the php package clarkwinkelmann/flarum-mithril2html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package flarum-mithril2html

Flarum Mithril2Html

Uses Chrome Puppeteer via Spatie Browsershot to render Mithril components as static HTML.

Follow Browsershot instructions to setup Node and Headless Chrome.

This is intended for use with emails or other offline content generation.

It's probably not a good idea to use this outside of a queue because of the delays it introduces.

Usage

In your extension's extend.php, call the setup extender before registering any asset:

The extender can be called by multiple extensions without issues. It won't do anything once already registered.

Create a new page just like you would a normal Flarum page:

To save up space in the forum bundle or to prevent conflicts, you can add your page only to the mithril2html frontend. You will need to update your webpack config to add an additional entry file, see this package's webpack.config.js for an example.

If you created a separate bundle (not forum), register it using Flarum's Frontend extender:

If you already have a forum bundle with exports, Flarum will unfortunately override all forum exports with mithril2html exports (even if you have none). To work around this, a different extender is available just for javascript:

You can then use the Renderer class to render the component:

Alternatively, you can use the blade directive directly:

You can configure additional options using a component class. The class must implement ClarkWinkelmann\Mithril2Html\ComponentInterface. AnonymousComponent is a simple class that allows customizing all parameters without creating additional classes.

The parameters customizable through a component class are:

Using a custom component class helps keep things clean when preloading is necessary:

PDF and Screenshot

While it was not the primary use case for this extension, the Renderer class also exposes a browsershot method that gives access to a pre-configured but unused Browsershot instance.

When using that method, the selector property is ignored and the entire page/viewport is used. Browsershot methods must be used to configure the output.

Example:

The page CSS is not loaded when calling Renderer::render but is loaded by default when calling Renderer::browsershot. It can be disabled by passing false as the second argument like $renderer->browsershot($component, false).

Known issues

At the moment, passing an actor will authenticate the base request and preloaded apiDocument, but not any additional API request the component will make after page load.

If you render a page with user-generated content and an XSS is possible, the attacker might be able to read any API GET endpoint as administrator by first stealing the mithril2html internal token and then using that token to preload arbitrary GET endpoints.

Tests

The integration tests are a bit special because they require a working webserver that can be accessed by Chrome.

Run composer test:server before running the tests to start the PHP development server on port 8080. The server is configured with a router script that takes care of routing back to the integration tmp folder.


All versions of flarum-mithril2html with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
flarum/core Version ^1.2
spatie/browsershot Version ^3.0
symfony/dom-crawler Version ^5.0
symfony/css-selector Version ^5.0
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package clarkwinkelmann/flarum-mithril2html contains the following files

Loading the files please wait ....