Download the PHP package gigablah/silex-view without Composer

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

ViewServiceProvider

Build Status Coverage Status

The ViewServiceProvider gives engine-agnostic templating capabilities to your Silex application.

Installation

Use Composer to install the gigablah/silex-view library by adding it to your composer.json. You'll also need a rendering engine, such as Mustache.

Usage

Just register the service provider and optionally pass in some defaults.

The provider registers the ArrayToViewListener which intercepts the output from your controllers and wraps it with a View object. For it to work, you have to return an array of data from your controller function.

Views

Normally you do not need to instantiate any view entities on your own; the listener will convert your controller output. If you wish to do it manually, the syntax is as follows:

Views can be rendered by calling the render() function, or casting to string:

Again, you should not need to render your views manually since they will be handled by the Response object.

View Context

The view entity is simply an instance of ArrayObject, so you can use regular array notation to set the context, along with convenience functions like with():

To insert into the global context, use share():

You can initialize the global context by overriding view.globals.

Resolving Templates

How does the listener know which template to use? By default it reads the _route attribute from the request entity in lowercase, and appends the extension based on the value of view.default_engine. Some examples:

Since you probably want more descriptive template names, you can use named routes:

You can also set the _template attribute in the request, or as part of the controller output:

If you need custom logic for generating template paths, you can create your own class that implements TemplateResolverInterface and override view.template_resolver.

Engines

This library does not handle any actual view rendering; that task is delegated to the templating library of your choice. Currently adapters are provided for:

There is a special DelegatingEngine which acts as a registry for multiple different engines, selecting the appropriate one based on the template file extension. Since Aura.View, Plates and Raw PHP all use the same default file extension (.php), you will need to manually configure the extension mapping as follows:

Composite Views

Views can be nested inside another:

For a single view, it is equivalent to:

However, the difference lies in nesting multiple views in the same location. Doing this will place the child views adjacent to each other rather than overwriting:

What's more, you can mix and match different engines:

Nested views will inherit the context of their parent views.

Exception Handling

All rendering exceptions are captured and stored in a shared ExceptionBag.

To access the last thrown exception, or return all of them:

More Examples

You can view a code sample of various usage scenarios in the demo application.

License

Released under the MIT license. See the LICENSE file for details.


All versions of silex-view with dependencies

PHP Build Version
Package Version
Requires silex/silex Version ~1.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 gigablah/silex-view contains the following files

Loading the files please wait ....