Download the PHP package machinateur/twig-block-validator without Composer

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

Twig Block Validator (for Shopware 6)

A twig block validator, inspired by the Shopware 6 IntelliJ plugin's twig block versioning. Pure PHP.

Inspiration

After visiting SCUC 2025 in Cologne, where it was mentioned and recommended multiple times, I held the idea that making twig-block validation possible via CLI would be a great help with CI for large shopware projects.

When dealing with many plugins and templates, it can get confusing quite fast. Let this tool help you with those twig blocks and validate if they're still up to date with their parent's content.

It also provides a way to automatically add and update the block version comment on your templates.

This project is still a beta version!

It's missing some guardrails, so edge-cases might still lead to internal errors or bugs.

Installation

Requirements:

In your shopware project or plugin, run:

Also make sure the bundle is available in the desired environments, usually dev and test. So in config/bundles.php:

Usage

This tool may also be used without Shopware, it supports both.

Examples with Shopware

Annotate whole project

Use the following commands to execute the validator for an existing Shopware Storefront project.

The above command will load all available templates based on the debug:twig command (JSON output), then validate @DemoVendor/basecom/demo-plugin/src/Resources/views.

The above command will load all available templates based on the debug:twig command (JSON output), then annotate @DemoVendor/basecom/demo-plugin/src/Resources/views and output the changed templates to var/twig-block-validator/templates. Omit the path, to do update annotations in-place.

Next, those can be used to patch or compare the template source code, which is typically tracked via a VCS.

Validate the tests/res_sw dir

To validate against the dev-dependency shopware/storefront:^6.4 installed at vendor/shopware/storefront/Resources/views, expecting version 6.7 in the comments in tests/res_sw/ (__main__ as default namespace), run:

Here's the example template that would produce the above errors:

I just generated a random SHA265 for this test.

It's also possible to use twig-block here, but since this was inspired by Shopware's PhpStorm plugin, shopware-block is also supported.

In general, the version is recommended, but since this tool is not strictly limited to working with shopware, it is not enforced. The provided version (-r flag) will be the default version, if none is set for a block. If not given, it will try to use the

Annotate @Storefront itself

The following command will go through the templates of shopware/storefront, put the annotation comment for those blocks, that extend another template (and therefor have a parent), and finally write the changed templates to ./var/cache/twig-block-validator/views.

The result:

How to validate

The validation can be performed by calling the CLI command twig:block:validate. Here's it's synopsis:

How to annotate

The annotation can be performed by calling the CLI command twig:block:annotate. Here's it's synopsis:

Caution! Always back up your templates and use a VCS. A bug or user error can cause permanent loss of data!

Which CLI to use

There are a total of four different CLIs available:

These can be copied to the bin/ directory of your project (if not already present).

Standalone

Note: The phar is still experimental, and does not support integrated use with shopware projects (yet).

The tool can be used as standalone, phar or source, for example in CI pipelines:

PHP is required. The source archive will need composer to be available and may also be used instead of git clone, when not available in your environment.

Find the source archive and prebuilt phar attached to the latest release.

Build the phar

This instruction requires box to be installed globally.

License

It's MIT.


All versions of twig-block-validator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
composer-runtime-api Version *
composer/semver Version ^3.4
machinateur/twig-comment-lexer Version ^1.0
symfony/cache Version ^7.2 | ^6.4 | ^5.4
symfony/console Version ^7.2 | ^6.4 | ^5.4
symfony/debug-bundle Version ^7.2 | ^6.4 | ^5.4
symfony/dependency-injection Version ^7.2 | ^6.4 | ^5.4
symfony/event-dispatcher Version ^7.2 | ^6.4 | ^5.4
symfony/finder Version ^7.2 | ^6.4 | ^5.4
symfony/framework-bundle Version ^7.2 | ^6.4 | ^5.4
symfony/monolog-bundle Version ^3.6
symfony/runtime Version ^7.2 | ^6.4 | ^5.4
symfony/twig-bundle Version ^7.2 | ^6.4 | ^5.4
symfony/yaml Version ^7.2 | ^6.4 | ^5.4
twig/twig Version ^3.15
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 machinateur/twig-block-validator contains the following files

Loading the files please wait ....