Download the PHP package phpgt/domtemplate without Composer

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

Bind dynamic data to reusable HTML components.

Built on top of PHP.Gt/Dom, this project provides dynamic data binding to DOM Documents, document templating and reusable HTML components.

Directly manipulating the DOM in your code can lead to tightly coupling the logic and view. Binding data using custom elements and data attributes leads to highly readable, maintainable view files that are loosely coupled to the application logic.


Build status

Code quality

Code coverage

Current version

PHP.G/DomTemplate documentation

Example usage: Hello, you!

Consider a page with a form, with an input element to enter your name. When the form is submitted, the page should greet you by your name.

Without submitting the form, the HTML will be rendered untouched, showing the default message "Hello, you!".

Source HTML (name.html)

The HTML below shows a basic "Hello, you" message, but due to the data-bind:text attribute, when the form is submitted, the PHP code binds the submitted name to the DOM at the correct place, greeting the user.

greeter.html:

PHP used to inject your name

Example usage: Shopping list

In the following example, the template of the HTML is defined, with a data-template attribute to indicate that the LI should be repeated for every item in the data, and a data-bind:text attribute to set the textContent of the LI to the value of each item in the data.

Note: when binding an array of strings (or Stringable objects), there is no need to specify a bind key for the data-bind:text attribute, however in the next example you will see how more complex data structures can be used to bind data at different locations within the template element.

shopping-list.html:

PHP used to inject a shopping list

Output

Advanced usage: bind database results directly to the page

In the following example, the data-template attribute is used to repeat the LI for every result in the dataset. This dataset represents data that would typically come from a database query or API, but for this example we're simply hard-coding the data.

Within the LI, you can see where the various fields will be bound:

Note that the actual structure of the HTML can be changed at any time, and it's just the data-bind and use of curly braces that define where the data is bound to.

user-list.html:

PHP used to inject the list

Output

Features at a glance


All versions of domtemplate with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-dom Version *
phpgt/dom Version ^4.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 phpgt/domtemplate contains the following files

Loading the files please wait ....