Download the PHP package corrivate/magento2-layout-bricks without Composer

On this page you can find all versions of the php package corrivate/magento2-layout-bricks. 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 magento2-layout-bricks

Layout Bricks for Magento

Latest Version on Packagist

All in all you're just another brick in the layout

Modern frontend frameworks embrace reusable components, like buttons, input fields, and cards. And they style them with utility CSS like Tailwind. It's fine to pile a dozen classes on that primary button, because you only have to build it once.

Magento doesn't come with this out of the box. Many templates are huge and if you talk about UI components people make the sign of the cross XML at you.

This package is a way to make things better. To use small anonymous components without hassle. It's heavily inspired by Laravel's anonymous blade components. In Magento, our unit of frontend template is a block. An anonymous block is a brick.

An example phtml template

How does it work?

The $mason object is globally injected into every .phtml template. It has just one method, __invoke(), to cause it to output as a string a fully rendered child block. So it's essentially a compact, ergonomic way of doing this:

This is already nice, because we are now still using Magento's templating engine:

But there's more:

For example, consider the cms.block brick:

This will render the CMS block with ID 'text-block', but surround it in a div with a gray round border.

Aliases

Aliases in detail

You can place bricks in two ways:

Aliases in detail

Attributes

Attributes in detail

The $mason objects invoke method accepts an array of attributes. For example:

In the brick template, this will be available as a BrickAttributesBag which could for example have the following default attributes/values:

This would result in the following HTML after the defaults and your custom input is merged:

Attributes in detail

Props

Props in detail

Props are used to pass data to the brick. For example, if you were making a brick to render a "product card", you'd pass the product that needs to be displayed:

In the brick template, the props are available through the $props variable, which is automatically present:

The $props variable is not an array, but it implements ArrayAccess to give access to its contents.

The $props variable also has a $props->default([]) method so you can supply default (scalar) props. You can always override those default from the parent template.

The $props object also has a $props->expect([]) method which allows you to specify expected props and their data types so you can opt into greater type safety.

Props in detail

Escaper

Using $escaper to filter raw output of data from the DB or user input is important to protect against various attacks. Official documentation about this.

However, the output from $mason() is the output of another block that already produces HTML. So the call to $mason() should NOT be escaped, but inside the PHTML template implementing your brick, you should use it normally.

Empty PHTML brick template

Just copy paste this into a file and start designing:

Corrivate

(en.wiktionary.org)

Etymology

From Latin corrivatus, past participle of corrivare ("to corrivate").

Verb

corrivate (third-person singular simple present corrivates, present participle corrivating, simple past and past participle corrivated)

(obsolete) To cause to flow together, as water drawn from several streams.


All versions of magento2-layout-bricks with dependencies

PHP Build Version
Package Version
Requires php Version ~7.4.0||~8.0.0||~8.1.0||~8.2.0||~8.3.0
magento/framework Version *
magento/module-cms Version *
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 corrivate/magento2-layout-bricks contains the following files

Loading the files please wait ....