Download the PHP package micky/mkyengine without Composer

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

MkyEngine

PHP template engine by Micky-N
Latest Stable Version Generic badge

The template engine uses the block and extension system to define the different parts of the view.

Installation

composer require micky/mkyengine

Usage

Directory Loader

The directory loader register view directory for template engine

If you want to define component or layout subdirectory use setComponentDir or setLayoutDir

component directory will be views_dir/components_dir and layout directory will be views_dir/layouts_dir

Environment

The environment stores all directories with the namespace and file extension of the view, you can optionally define shared variables

By default, the first namespace is root, you can add another directory loader and its namespace with the method addLoader()

To use view, component or layout from another namespace use @namespace:view

View Compiler

The view compiler compiles the view by retrieving the blocks and displaying them in the layout sections. The first parameter is the environment, the second is the view to be displayed and the third is the view variables.

To render the view use render() method

Templating

Layout

The layout is a background for the views, you can define which parts of the layout will be filled by the view.

You can define a default value in the section that will be used if no 'title' block is defined.

Layout view can extend another layout.

Block

Extends

Extends method is used to define the layout file.

Blocks are a part of view use for layout. The param is the block name

You can set a simple block with a second parameter

To display this block use section() method in the layout with the block name to display

You can define several blocks with the same name

It will show

Thanks to that, blocks can be conditioned by the method if()

Injection

Thanks to injection method $this->inject you can set object used for HTML template like number formatter or form builder as View property

Example FormBuilder:

In the view:

The first parameter is the name of property you want to register in the view instance and the second is the class to instantiate, you can pass a class instance or a class name. You will be able to use class via $this->nameOfProperty

The HTML rendering will be:

Component

The component is a view piece, useful if you want to use it in several views.

You can pass a variable to the component with the method bind(), the first parameter is the component variable and the second is the value.

You can pass multiple variables to the component with the method binds().

Same as block class, components can be conditioned by the method if()

You can repeat a component in loop with 2 methods:

For loop

The first parameter is the number of iterations, the second is a callback that will be called at each iteration. In callback the first parameter is the view params, the second is the current loop index.

Example: in name-input.php component there a variable called 'name' for an input, with the callback each iterated component will have the name of the current user

Each

With the method each() , the component will iterate for each array value. The first parameter is the array and the second can be a callback, an array or a string.

Callback

The each() callback is the same as the for() callback but with a third parameter that it's the array.

Array

You can bind variable with an array that index is the component variable and the value is the object property or array key of data $users

If you need to pass a nested value, you can do so by concatenating address.postcode it's equal to:

Example:

All properties and nested properties are accessible if the property exists or a getter, like for postcode, getPostcode() exists or a magic method exists

String

The component may need the object or array as parameter (like one user of users), for that you can set in the parameter the name of current iterated data

Else component

If the data $users is empty you can set a third parameter as string to define the else component

Component slot

In the case you have a component which you want to make the body dynamic like:

A simple alert component with a conditional button, to use this in your view, you have to set three slots: the default, confirm and close slot

The HTML rendering will be:

All texts not in a slot will be placed in the default slot. Slots can be conditional:

You can also make a default value for empty slot to avoid error message

Licence

MIT


All versions of mkyengine with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 micky/mkyengine contains the following files

Loading the files please wait ....