Download the PHP package rsc/components without Composer

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

RSC Components

A slim, discreet, reusable component library and framework to ease interoperability between various parts of a Magento2 installation.

Components

For the purposes of this extension, a component is any portion of HTML markup that will be rendered onto the page using an assortment of PHP variables, and which may in the future, be reused. If you think there is even a chance that your markup will be reused, make it a component.

Structure

Components all inherit the Base component, and are grouped into various categories:

Components' templates reside in the extension's view/frontend/Components directory. When you create new components, please place your new components in its corresponding directory.

Creating a New Component

First thing's first: we want this component to be tested. If it's not tested, it's not working. So figure out where in the directory (Components/Model) your component belongs (create a new one if you want), and create the MyComponent.test.php file.

Testing

We have eschewed a bulky testing framework for testing these components, since the goal is to be lightweight and ensure basic functionality tests at the PHP level. For ensuring more robust UI testing and hunting down regressions, the component library is intended to be displayed on a styleguide or pattern library.

When you create your own tests, test the most basic unit available that you are fairly sure will always be the responsibility of this component.

For example, if you make a link component, you may not be sure that the link will have a class, title, or id attribute. But because it is a link, you can be pretty certain that it will have a href attribute, and contain some content text. So let's test those.

This basic test will ensure that what we output is indeed a link, that it contains a href attribute, that the link itself appears somewhere in the rendered output, and the same for the link text.

Now you can test your component by either CDing into the directory and running php Link.test.php, or in the Components base directory, run php Tests.php, which will test all of your components.

Component Class

Creating a component is as simple as creating both the class and the template that the class renders. To continue our link example:

This is a simple component that needs no special handling of variables before being rendered. If you want information on what you would do to add pre-rendering customizations, see Components/Model/Base.php, and some of the built-in components.

Templates

Templates are standard .phtml files that render markup given a handful of variables passed to the component via the setVariable($key, $value) or the setVariables($variables = []) classes. The script extracts the variables so that, e.g., ['url' => 'http://www.google.com'] becomes just $url = 'http://www.google.com';.

Template Helper Methods

The base class provides you with a slew of helpers to shorten your components and elevate display logic out of your components as much as possible.

For examples of where these are used, see the templates provided in the default components.

Using Components

Components are intended to be used beyond the scope of Magento2, and should not themselves require anything except raw data that they turn into rendered HTML.

Therefore, there are three ways to call components:

Indirectly, from within Templates and Blocks

This plugin attaches a reference to the primary instance of the ComponentManager to every Magento2 block, so that if you are in a block context (that is, most of Magento2 where you may use components), you can simply call this class via $this->ComponentManager->....

Indirectly, via Magento2 Dependency Injection

If you prefer to configure and render your components prior to the Magento2 core template .phtml files, and defer it to somewhere outside of a block or template context, you can always access the component manager by injecting it via Dependency Injection in Magento2.

You would create the following di.xml for your module:

Directly (not preferred)

If you, for some reason, need to use a component outside of the context of Magento2, you can easily call these components by merely creating a new instance of the Components/Model/ComponentManager() class. This class is a factory for creating and handling the entire component library.

Because we can cache certain components, however, this method is not preferred within the context of Magento2.

Suggested use case: within a styleguide showcasing how to use and modify your Magento2 components.


All versions of components with dependencies

PHP Build Version
Package Version
Requires php Version ~5.6.5|7.0.2|7.0.4|~7.0.6
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 rsc/components contains the following files

Loading the files please wait ....