Download the PHP package tollwerk/tw-componentlibrary without Composer

On this page you can find all versions of the php package tollwerk/tw-componentlibrary. 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 tw-componentlibrary

tw_componentlibrary

Component library features for your TYPO3 project

About

This TYPO3 extension

  1. encourages and supports the development of self-contained, re-usable function and design modules ("components") along with your TYPO3 project and
  2. exposes these components via a JSON API so that component or pattern library, testing and styleguide tools like Fractal can extract and render your components individually and independently of your TYPO3 frontend.

Usage

Installation

Install the extension into your composer mode TYPO3 installation:

Alternatively, download the latest source package and extract its contents to typo3conf/ext/tw_componentlibrary.

Enable the extension via the TYPO3 extension manager.

Component types

The extension distiguishes 5 main types of components:

The extension doesn't impose any requirements towards your TypoScript, Fluid templates or directory layout except that every component must be individually addressable. That is, you cannot expose e.g. just a part of a rendered Fluid template as a component. In that case, you'd have to outsource the desired part as a partial file of its own.

Declaring components

You can declare components either manually (described below) or using the command line component kickstarter .

  1. Create and install an empty TYPO3 extension that is going to hold your component definitions. Alternatively, pick an existing extension you've got write access to. It's possible to have multiple of these component provider extensions. If you're using and maintaining custom extensions anyway, I recommend using these for providing components on an per-extension basis.
  2. Create a Components directory inside the provider extension's root directory. In case you're running TYPO3 in composer mode, make sure this directory is properly mapped to the Component namespace. You might have to add something like this to your main composer.json file (replace the vendor name, extension key and paths with appropriate local values):

  3. Especially if you're going to have a lot of components it's advisable to organise them in a hierarchical structure. Create a suitable directory layout below your Components folder to reflect this hierarchy. Use UpperCamelCase directory names without spaces, underscores and special characters — external systems can use the word boundaries for transforming these e.g. into a navigation tree. Your directory layout could look something like this:

  4. Start creating component declarations by creating PHP class files at appropriate locations in your directory layout. Each file must declare exactly one class extending one of the main component type base classes (see below). The file and class names must be identical, should be in UpperCamelCase and must end with the suffix …Component (respectively …Component.php for the file name). The part before …Component will be used as the component by external tools. In addition to the base version of a component you may provide variants of that component by adding an underscore and appendage to the file and class name. System like Fractal can use this for a grouped display of component variants:

  5. Use the configure() method of your component declaration to specify the individual component properties. While each component type brings a small set of specific properties (see below), the majority of instructions is common to all component types.

TypoScript component

Use the setTypoScriptKey() method to specify the TypoScript object that renders the component output. The key will be evaluated for the page ID specified by the $page property (see common properties).

Fluid template component

Use the setTemplate() method to specify the Fluid template file that renders the component output. Specify rendering parameters using the setParameter() method (works just like $this->view->assign('param', 'value') in Extbase controller actions).

For convenience reasons, Fluid template components can read in external JSON files for setting parameters. JSON parameter files must be named after their associated component files and lie in the same directory:

The key / value pairs inside the JSON file will be used as input for the setParameter() method.

Extbase plugin component

To configure an Extbase plugin component, use the setExtbaseConfiguration() method to specify the plugin name, the controller class name and the controller action to be called. The output will be rendered using the Fluid template associated with the controller action. You can specify action arguments via setControllerActionArgument() and simulate controller controller settings via setControllerSettings().

Content component

Use the setContentRecordId() method to specify the UID of an existing content element (tt_content table) that you want to render as a component (please make sure the content element is accessible / isn't hidden by any means).

Form component

Inside your component definition, you must use the createElement() method to instantiate a renderable form element (TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable). This is basically the same object that you get via the Form Framework's Page::createElement() method during API form composition. You can further configure the form element using its native methods (as you would do in a form factory class).

To simulate a form validation error for your element, simply call addElementError($message) (the element must have been instantiated prior to adding errors). You can registrer multiple errors.

It is advised but not mandatory to register the form field's Fluid template using setTemplate() for a nicer display in your component library.

Common properties

There's a bunch of component properties and methods that are common to all component types. Some of them are controlled via shared configuration methods.

TypoScript constants

Use the TypoScript constants to globally configure the HTML documents wrapped around your components when rendered by external systems. You can add base files, web fonts and libraries this way (global.css, jQuery, etc.). All resources can be referenced absolutely (starting with http:// or https://), relatively (/fileadmin/css/...) or using a TYPO3 extension prefix (EXT:ext_key/Resources/...).

TypoScript-Namensraum: plugin.tx_twcomponentlibrary.settings

Constant Type Default Description
stylesheets String Empty Comma separated list of CSS stylesheets to be included for all components.
headerScripts String Empty Comma separated list of JavaScript resources to be included in the <head> section for all components.
footerScripts String Empty Comma separated list of JavaScript resources to be included right before the closing </body> element for all components.
Component properties

There are a couple of protected object properties you can override in your component classes to alter the default behaviour.

Property Type Default Description
$page int 1 TYPO3 page ID used when requesting the component (might affect effective TypoScript)
$typeNum int 0 type parameter used when requesting the component
$sysLanguage int 0 System language UID used when requesting the component.
$languageParameter string "L" Language parameter name (used as GET variable name)
$label string Empty Alternative label for the component (might be used by external systems)
$status string "wip" Arbitrary component status label for use in external systems
$request Request¹ Request¹ Web request object used for requesting the component. You can add arguments with $request->setArgument('name', 'value')
$preview TemplateInterface² FluidTemplate³ Preview template used for rendering the component for external systems. Supports a couple of configuration methods, see below.
$dependencies array Empty array List of class names of components the current component depends on (by nesting). CSS and JavaScript resources required by nested components will automatically be pulled into the rendering process. The component dependency graph will show a visual connection to all registered dependencies.

Example usage:

Configuration methods

Use the following methods to further configure your components.

Preview templates

By default, the builtin FluidTemplate is used for rendering components for external systems. You can use your custom template as long as you implement the TemplateInterface. The default FluidTemplate supports a couple of configuration methods:

Example usage:

Documentation

You can add documentation to your components in two ways:

  1. By using addNotice($str) inside the configure() method of a component.
  2. By creating a documentation directory named after the component (without variant suffix) and dropping documentation files in there. When the component is extracted,

    • it will first be checked if a file named index.md, readme.md or <component>.md exists inside that directory. If it does, this file will be used as the main documentation.
    • If there's no such documentation index, a simple Markdown listing will be generated, enumerating all the files in the directory. Valid image files will be embedded as images, otherwise the linked file name will be shown.

    Example:

    During component extraction, linked files in the documentation (including images) will be rewritten to their root relative path starting at your TYPO3 main directory.

Directory configuration

As of version 0.3.2, you can add directory specific configuration values to your component directory layout. When exporting a component, the values for each of its parent directories will be exported as well. Add configuration values to a directory by creating a file called local.json containing an arbitrary JSON data structure, e.g.

It's up to the consuming application to use these values for particular purposes. The TYPO3-Fractal-bridge for example uses the dirsort value for ordering the directories other than alphabetically and label for component folder names that couldn't be achieved via real file system directory names.

Command line component kickstarter

The extension provides a command line component kickstarter which let's you scaffold new components with ease. It's implemented as an extbase CLI command:

The command takes 4 arguments (in the following order; you can also enter it with explicit argument names):

The above command will kickstart a Fluid component named Button at this location inside the tw_tollwerk extension:

If you're mostly adding components to a particular provider extension, you can simplify the process by defining a default provider extension along with its corresponding default vendor name. To do so, please enter the extension configuration in the extension manager and provide these two settings:

You can then omit the --extension and --vendor arguments when calling the CLI command:

Extracting components

The extension adds an Extbase CLI command that lets you discover the declared components in JSON format on the command line:

Sample result:

Use the exposed JSON data in any way that makes sense for you. The Fractal-TYPO3 bridge, for instance, builds an explorable component library out of it.

Important note: As of version 1.0, the components declared by an extension will only be exported if the TypoScript setup of the extension features a features.exportComponents key with value 1. This is expected to be found at plugin.tx_myext in the overall TypoScript configuration, where tx_myext is built from the prefix tx_ and your extension key without underscores:

You can make this configurable via the extension constants. The component library extension comes with a language label you can use for that (in constants.typoscript):

Rendering components

The extension introduces the new type parameter value 2400 which is used for calling TYPO3 as rendering engine for single components. The request

http://example.com/?type=2400&tx_twcomponentlibrary_component%5Bcomponent%5D=Vendor%5CExtKey%5CComponent%5CMyWidgetComponent

will exclusively render the component \Vendor\ExtKey\Component\MyWidgetComponent and return the generated source code without surrounding page level HTML.

Component dependency graphs

The extension introduces the new type parameter value 2401 which is used for dynamically rendering component dependency graphs. The request

http://example.com/?type=2401&tx_twcomponentlibrary_component%5Bcomponent%5D=Vendor%5CExtKey%5CComponent%5CMyWidgetComponent

will create a single component dependency graph like this one:

Single component dependency graph

To create an overview graph of all registered components, simply omit the component argument. The URL

http://example.com/?type=2401

will create a graph like this one:

Overview component dependency graph

You can use these graphs for documentation purposes or to display them in the Fractal component library tool.

Utilities

SvgIconUtility

The included class \Tollwerk\TwComponentlibrary\Utility\SvgIconUtility helps you with listing SVG graphics in backend forms and custom applications. Provide a comma-separated list of directories using the TypoScript constant plugin.tx_twcomponentlibrary.settings.iconDirectories. The following two methods will then find and return all *.svg files in these directories.

SvgIconUtility::getIcons(int $id = 1, int $typeNum = 0): array

Returns an array of SVG graphics, with the file base names as values and the absolute file paths as keys. Optionally provide a page ID and type for which the icon directories should be determined.

SvgIconUtility::getIconTcaSelectItems(int $id = 1, int $typeNum = 0): array

Similar to getIcons(), but returns the graphics ready for use in TCA select fields.

TYPO3 Backend integration

The extension provides a simple integration so that you can update your component library from within the TYPO3 backend. So far, only the Fractal component library is supported. To enable Fractal support, follow these simple steps:

Contributing

Found a bug or have a feature request? Please have a look at the known issues first and open a new issue if necessary. Please see conduct for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

Copyright © 2018 Joschi Kuphal / [email protected]. Licensed under the terms of the GPL v2 license.


All versions of tw-componentlibrary with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
typo3/cms-core Version ^10.0
alom/graphviz Version ^1.1
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 tollwerk/tw-componentlibrary contains the following files

Loading the files please wait ....