Download the PHP package xwero/laravel-twig-html without Composer

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

laravel-twig-html

This is a html builder twig extension for people who use Twig in Laravel.

The Laravel twig integration package comes with a formbuilder extension that uses LaravelCollective/html. This package is abandoned, with the suggestion to use spatie/html.

My package uses the suggested library, maybe in a quirky way. But I saw the fluent API of the library, and I wanted the same in twig.

The out of the box twig integration code: {{ form_open({"route":"home"}) }}

Laravel twig html code: {{ h()|e_form|form_route("home")|em_open }}

As you can see this package involves more typing. I will add some shortcuts for frequently used combinations.

Usage

The function html() can not be rendered on its own. It is the start value to create the tags. The short version is h().

The element filters are prefixed with e_. And the element method filters are prefixed with em_. The difference between the two is that the element filters are standalone, while the element method filters need an element for the filter to work.

When you add a string as an argument it will be used as the first argument of the underlying method. You can add the arguments as a list, but then the amount of items has to be the same as arguments of the underlying method. To substitute the default arguments you can use named keys that match the default argument keys.

The defaults are pragmatic but when a combination of arguments can't result in usable html tag, the previous value will be returned. For the element filters this means an error object can be returned. For the element method filters there will be no changes.

Developing

You can run tests with ./vendor/bin/pest.

Unfortunately the form_route filter uses the route method without a slash so it looks for it in the Form class. Just add the slash, and all tests will run.

Other Laravel behaviours, like form_token, can not be tested without adding it to a Laravel project.


All versions of laravel-twig-html with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
spatie/laravel-html Version ^3.2
twig/twig Version ^3.7
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 xwero/laravel-twig-html contains the following files

Loading the files please wait ....