Download the PHP package locomotivemtl/charcoal-view without Composer

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

Charcoal View

The Charcoal\View module (locomotivemtl/charcoal-view) provides everything needed to render templates and add renderer to objects.

It is a thin layer on top of various rendering engines, such as mustache or twig that can be used either as a View component with any frameworks, as PSR-7 renderer for such frameworks (such as Slim)

It is the default view layer for charcoal-app projects.

Build Status SensioLabsInsight

Table of content

How to install

The preferred (and only supported) way of installing charcoal-view is with composer:

To install a full Charcoal project, which includes charcoal-view:

Dependencies

Optional dependencies

👉 Development dependencies are described in the Development section of this README file.

Basic Usage

A View can be used to render any template (which can be loaded from the engine) with any object (or array, for twig) as context.

Basic Usage, with service provider

All this bootstrapping code can be avoided by using the ViewServiceProvider. This provider expects a config object

👉 The default view engine, used in those examples, would be mustache.

Using the Renderer, with Slim

A view can also be implicitely used as a rendering service. Using the provided view/renderer, with a PSR7 framework (in this example, Slim 3):

Just like the view, it is possible to simply register all dependencies on a Pimple container (with the ViewServiceProvider) to avoid all this bootstrapping code. The renderer is available as $container['view/renderer'].

Module components

The basic components in charcoal-view are:

Views

The Charcoal\View\ViewInterface defines all that is needed to render templates via a view engine:

The abstract class Charcoal\View\AbstractView fully implements the ViewInterface and adds the methods:

Generic view

As convenience, the \Charcoal\View\GenericView class implements the full interface by extending the AbstractView base class.

View Engines

Charcoal views support different templating Engines_, which are responsible for loading the appropriate template (through a loader) and render a template with a given context according to its internal rules. Every view engines should implement \Charcoal\View\EngineInterface.

There are 3 engines available by default:

Mustache Helpers

Mustache can be extended with the help of helpers. Those helpers can be set by extending view/mustache/helpers in the container:

Provided helpers:

Loaders

A Loader service is attached to every engine. Its function is to load a given template content

Templates

Templates are simply files, stored on the filesystem, containing the main view (typically, HTML code + templating tags, but can be kind of text data).

Templates are loaded with template loaders. Loaders implement the Charcoal\View\LoaderInterface and simply tries to match an identifier (passed as argument to the load() method) to a file on the filesystem.

Calling $view->render($templateIdent, $context) will automatically use the engine's Loader object to find the template $templateIdent.

Otherwise, calling $view->renderTemplate($templateString, $context) expects an already-loaded template string as parameter.

Viewable Interface and Trait

Any objects can be made renderable (viewable) by implementing the Charcoal\View\ViewableInterface by using the Charcoal\View\ViewableTrait.

The interface adds the following methods to their implementing objects:

Examples

Given the following classes:

The following code:

would output: "Hello world!"

View Service Provider

As seen in the various examples above, it is recommended to use the ViewServiceProvider to set up the various dependencies, according to a config, on a Pimple container.

The Service Provider adds the following service to a container:

Other services / options are:

The ViewServiceProvider expects the following services / keys to be set on the container:

The View Config

Most service options can be set dynamically from a configuration object (available in $container['view/config']).

Example:

Development

To install the development environment:

Run tests with

API documentation

Development dependencies

Continuous Integration

Service Badge Description
Travis Build Status Runs code sniff check and unit tests. Auto-generates API documentation.
Scrutinizer Scrutinizer Code Quality Code quality checker. Also validates API documentation quality.
Coveralls Coverage Status Unit Tests code coverage.
Sensiolabs SensioLabsInsight Another code quality checker, focused on PHP.

Coding Style

The Charcoal-View module follows the Charcoal coding-style:

Coding style validation / enforcement can be performed with composer phpcs. An auto-fixer is also available with composer phpcbf.

Authors

License

Charcoal is licensed under the MIT license. See LICENSE for details.


All versions of charcoal-view with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0 || >=7.0
psr/log Version ^1.0
psr/http-message Version ^1.0
locomotivemtl/charcoal-config Version ~0.8
erusev/parsedown Version ^1.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 locomotivemtl/charcoal-view contains the following files

Loading the files please wait ....