Download the PHP package coreorm/slim3-view without Composer

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

slim3-view

Build Status

View renderer for slim3 with very straightforward and simple (yet still customisable) theme/layout/templates structure.

This also works with any PSR-7 compliant response objects.

Example

Requirement

Install

composer require coreorm/slim3-view

Test

phpunit

Structure

make sure your themes directory are in the following structure:

Layout template

Layout template must contain a default variable $mainContent in the body so sub templates can appear, e.g.

Another way to send rendered content to the page is to use $theme->renderView(), e.g.

Usage Example (or just open up examples/app/index.php):

APIs

Theme APIs

Theme::instance($templatePath = null, $theme = 'default')

instantiate the theme class: We use a singleton pattern to ensure all shared data are available to each and every template, so simply use:

$theme->setLayout($layout)

switch layout: It's possible to switch layout either from the beginning of the code, or inside the routes at run time.

E.g.

$theme->setTheme($theme)

switch theme: This will set the current theme to the string value of $theme.

$theme->share($templateRelativePath, $theme)

mark a template from a specific theme as shareable: this will essentially make it a global template to go to when a template with the same name from a different theme is not found.

E.g.

This will mark the page themes/default/views/page1.phtml as the shared view for relative path views/page1, so if say I'm in theme 'new' and I call renderView('page1'), if themes/new/views/page1.phtml doesn't exist, it will use themes/default/views/page1.phtml instead.

$theme->render(ResponseInterface $response, $template, array $data = [], $shouldFallback = false)

render a template plus the layout: This is the final render function you'd want to run in your route/controller, as it renders the give template and assigns it to the $mainContent partial data which in turn will be displayed in the template main body (or wherever you would like to, by calling ``). So it renders template, then layout, and then output to the browser.

E.g.

$theme->renderView($template, $data = [], $shouldFallback = true, $reuseHTML = false)

render a template and retrieve the content: This renders a template and will return the html.

$reuseHTML if this is set to true, the given template will render only once, and any future renderView/import calls to this template will reuse the HTML that's rendered from the very first one. Use this for elements that are repeated on the same page with exactly the same HTML source.

E.g.

Template (layout/views) API

$this->import($templateFile, $data = [], $shouldFallback = true, $reuseHTML = false)

import a sub template inside a template This is only available inside the template itself.

In the template code, do:

Data scope

Global (data available to all templates)

$theme->setData($k, $v) sets data that is available for all templates/layouts;

Private (partial data that will override global data, when used for rendering individual views)

passing partial data to the render/import function will set data that is private to the given template only. e.g. $theme->render($response, 'page', ['foo' => 'bar']) will set the $foo value to 'bar' only for the page template.


All versions of slim3-view with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
psr/http-message 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 coreorm/slim3-view contains the following files

Loading the files please wait ....