Download the PHP package elvenspellmaker/glaza without Composer

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

Глаза (Glaza)

Глаза is a very basic view handler and parser for PHP views.

Installing

Installing can be done through Composer:

composer require ElvenSpellmaker/Glaza

If you don't want to use Composer, then clone the repo and include the provided AutoLoader:

Now all classes can be loaded as needed.

Why Глаза?

Glaza means eyes in Russian, and views are things you see the application through.

I was tired of templating frameworks either being too large or depending on too many other packages and wanted something quick and dirty to parse PHP views to separate my logic from my presentation code.

Basic Usage

The first step is to either install the package through Composer or to include the Autoloader to load the classes.

The next step is to create a view:

This will look for a file in current working directory called ViewTestHtml.php, if this doesn't exist an SPL RuntimeException will be thrown.

You may now assign data to the view to appear in the templates:

Views can contain other views too:

Rendering A View

In ViewTestHtml.php is the code:

Rendering Views is really easy. Either call their render method, or typecast them to a string, either by an explicit cast (string) or by trying to echo the view: echo $view.

Note: Views are rendered from the inside-out, which while it makes sense is worth pointing out.

Using the above exmaple the output is shown below:

Automatic Escaping (Sanitisation)

Consider the following code:

The above will render as <b>Not Bold</b> --> Not Bold because by default htmlspecialchars() is used to sanitise input. In order to override this, pass false as the third argument to View::set:

This will render as <b>Bold/b> --> Bold which might be what you wanted!

Finding Views In Other Directories

It's very likely you want to find your views in other directories and this is possible in two ways:

  1. Specify the full path to the View as you create the View: $view = new View( '/full/path/to/view' );
  2. Use the ViewManager class and add paths to search through. (This will be ultimately slower especially with the more paths that are added)

An example of method 2 is shown below:

Now when you create a new view it will first search the current working directory and then search the added directory. The order the directories are searched in is the order in which they are added. It it possible to add the path to be added to the beginning of the path list, by passing false to ViewManager::addViewPath as a second parameter. This will array_unshift the path to the front of the list.


All versions of glaza with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.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 elvenspellmaker/glaza contains the following files

Loading the files please wait ....