Download the PHP package performing/twig-components without Composer

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

Twig components extension

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This is a PHP package for automatically create Twig components as tags. This is highly inspired from Laravel Blade Components.

Installation

You can install the package via Composer:

Configuration

This package should work anywhere where Twig is available.

To enable the package just pass your Twig environment object to the function and specify your components folder relative to your Twig templates folder.

Craft CMS

In Craft CMS you should do something like this.

The if statement ensure you don't get 'Unable to register extension "..." as extensions have already been initialized' as error.

Symfony

In Symfony you can do something like this.

OctoberCMS / WinterCMS

In OctoberCMS / WinterCMS you need to hook into event inside your plugin's boot method in order to access twig instance. Then you can use your plugin hint path to choose a views subfolder as component's folder.

Usage

es.

then in your htm files

Alle features like subfolders are supported, like will refer to

The components are just Twig templates in a folder of your choice (e.g. components) and can be used anywhere in your Twig templates. The slot variable is any content you will add between the opening and the close tag.

Custom syntax

To reach a component you need to use custom tag x followed by a : and the filename of your component.

You can also pass any params like you would using an include. The benefit is that you will have the powerful attributes variable to merge attributes or to change your component behaviour.

To reach components that are in sub-folders you can use dot-notation syntax.

HTML syntax

The same behaviour can be obtained with a special HTML syntax. The previus component example can alse be used in this way.

Named slots

Also with the standard syntax.

Attributes

You can pass any attribute to the component in different ways. To interprate the content as Twig you need to prepend the attribute name with a : but it works also in other ways.

Twig Namespaces

In addition to the specified directory, you can also reference components from a Twig namespace by prepending the namespace and a : to the component name. With a namespace defined like so:

Components can be included with the following:

Dynamic Components

Sometimes you may need to render a component but not know which component should be rendered until runtime. In this situation, you may use the built-in dynamic-component component to render the component based on a runtime value or variable:

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Testing

License

The MIT License (MIT). Please see License File for more information.


All versions of twig-components with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
twig/twig Version ^3.0
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 performing/twig-components contains the following files

Loading the files please wait ....