Download the PHP package brightnucleus/view without Composer

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

Bright Nucleus View Component

Build Status Latest Stable Version Total Downloads License

This is a reusable View component that can provide different implementations (in separate, optional packages).

Table Of Contents

Installation

The best way to use this component is through Composer:

Basic Usage

The simplest way to use the View component is through its Facade: BrightNucleus\Views.

This Facade makes use of a basic BaseView View implementation as well as a basic PHPEngine Engine implementation. It can just be used as is and does not need additional configuration.

Adding Locations

You can add locations via the static View::addLocation($location) method. Each location needs to implement the Location. The View component comes with one location provider out of the box: FilesystemLocation.

Here's how to add a set of folders as a new location:

Rendering A View

To render a view, you pass a view identifier to the static View::render($view, $context, $type) method.

The $view is a view identifier that would normally be a template file name, but can also be something else depending on your configured locations & engines.

The $context array you pass in will be extracted to be available to the template at the time it is rendered.

The $type argument allows you to inject a specific view/engine combination, instead of letting the View component find one on its own.

Note: In order for a view to be effectively rendered, it needs to be found amongst one of the locations that were already registered.

Here's how to render a simple view:

Context

From within the template that is being rendered, the context variables are available as properties.

As an example, for the view we rendered above, you could use echo $this->userId; from within the template to retrieve that specific piece of context data.

If you add invokable object to the context as properties, they will in effect act as methods within the view template.

The context as a whole is available through the method $this->getContext(), which will return an associative array.

Keep in mind that no automatic escaping is taking place, the value of the context data is passed as-is.

Sections

To render a different template as a section from within the template currently being rendered, you can use the $this->section($view, $context, $type) method.

This does basically the same thing as an external render() call of a View object, with the following differences:

Here's an example of how this works:

Advanced Usage

For more advanced use cases, you'll want to provide custom classes for your Views or Engines.

Instantiating A Custom ViewBuilder

To do this, you'll want to create your ViewBuilder object manually, instead of relying on the Views Facade. By instantiating it manually, you can provide a custom Config to map your classes.

Once, you've got a ViewBuilder instance, you can use the addLocation($location) method to add locations to scan for views and the create($view, $type) method for creating an actual View. This View can then be rendered through its render($context) method.

Configuration Schema

Here's an example for providing a custom Config. In this case, we want to replace the default classes with more awesome ones.

Of course you don't need to override all of the classes, views or engines. If you only override specific keys, the rest will be taken from the default values.

Contributing

All feedback / bug reports / pull requests are welcome.

License

Copyright (c) 2016-2017 Alain Schlesser, Bright Nucleus

This code is licensed under the MIT License.


All versions of view with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
brightnucleus/exceptions Version >=0.4
brightnucleus/config Version >=0.5
doctrine/collections Version >=1.3
symfony/finder Version >=3.1
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 brightnucleus/view contains the following files

Loading the files please wait ....