Download the PHP package e0ipso/twig-storybook without Composer

On this page you can find all versions of the php package e0ipso/twig-storybook. 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 twig-storybook

Twig Storybook

GitHub GitHub release (latest by date) GitHub issues

Twig Storybook is a Composer package that enhances the Twig templating language by introducing two new Twig tags: stories and story. With Twig Storybook, you can easily create and manage Storybook stories directly in your Twig templates, making it a powerful tool for documenting and showcasing your frontend components.

Table of Contents

Installation

You can install Twig Storybook via Composer:

Usage

With Drupal

You don't need to use this package directly, use the Storybook drupal module instead. This library is compatible with Drupal 10, and later.

Adding Twig Tags

After installing the package, you need to register the Twig tags in your Twig environment. Here's how you can do it:

Creating Stories

Once the Twig Storybook extension is registered, you can start creating stories within your Twig templates. We recommend writing the stories in a file with name <file-name>.stories.twig.

Here's an example:

This will render as:

Storybook setup

Install Storybook as usual:

Then update .storybook/main.js to scan for stories where your application stores them.

Compiling Twig stories into JSON

The Storybook application will does not understand stories in Twig format. It will fail to render them. You need to compile them into a *.stories.json. To do so, you can leverage the StoryRenderer::generateStoriesJsonFile($template_path, $url) method. Where the $template_path is the location of the *.stories.twig template, and the $url is the base URL in your application that will render the story. Storybook will make a request to "$url . '/' . $hash", so make sure your application handles that route (see below).

The Drupal module implementation includes a console command to find all *.stories.twig and compile them into *.stories.json. See the implementation.

Rendering Stories

To render the Storybook stories, you can use the StoryRenderer service. Every framework handles routes differently, but we recommend using the story renderer inside your controller.

To use this service, wire the services to the container. The Twig Storybook Drupal module does it like this:

Contributing

We welcome contributions from the community. If you want to contribute to Twig Storybook, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and ensure all tests pass.
  4. Submit a pull request with a clear description of your changes.

Make sure to follow the code of conduct when interacting with this community.

License

Twig Storybook is open-source software licensed under the GPL-2 License.


All versions of twig-storybook with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-dom Version *
ext-mbstring Version *
psr/log Version ^1.0 || ^2.0 || ^3.0
symfony/dom-crawler Version ^4.4.45 || ^6 || ^7
symfony/http-foundation Version ^4.4.45 || ^6 || ^7
symfony/http-kernel Version ^4.4.45 || ^6 || ^7
twig/twig Version ^2.15.4 || ^3
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 e0ipso/twig-storybook contains the following files

Loading the files please wait ....