Download the PHP package jlorente/yii2-config-variables without Composer

On this page you can find all versions of the php package jlorente/yii2-config-variables. 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 yii2-config-variables

Yii2 Config Variables

A Yii2 Module to handle application configuration via database. Allows to modify variables content without tedious production deployments.

The Module includes the controller and views with the basic CRUD operations to include in your backend application, allowing you to modify the values of the configuration params directly in the production environment.

Introduction

Configuration variables are used in the application in order to store application configuration parameters. The motivation of this package is to avoid the use of of array because every time you want to change the value of some of these params, you must do it writting the params.php file and doing a production deployment.

With this plugin, you would be allowed to modify the configuration params of your application in your backend area without production deployments.

Installation

To install, either run

or add

to the section of your composer.json file and run the following commands from your project directory.

The last command will create the table needed to handle the config variables.

IMPORTANT!: If you downloaded the prerelease (<1.0.0) you should run the migration again.

Usage

Creating Variables

Configuration variables are used as part of the code to check its values at runtime, so should exist in order to be used and that is why they can't be created in the backend application directly but in a migration. In order to create a variable in a migration write:

Configuration variables available types are TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_BOOLEAN and TYPE_OBJECT.

TYPE_OBJECT is an special type that should be declared as a php associative array and its value checked as and stdObject class. An example of TYPE_OBJECT creation could be:

Listing, viewing and updating Variables values.

The extension comes along with a module to be set in your backend area in order to have the basic user interface operations for the Variable model. This module provides the actions to list all the variables of the application and to modify its values.

To load this module you must include it in your backend application.

./your-app/config/main.php

In this example I have used "config" as moduleId and will use this name for the rest of the examples, but you can use whatever name you want.

The route to the controller actions are:

Maybe you would want to include a link to the config/variable/index route in your backend navbar to make it accessible.

The module comes with english and spanish translations. If you want to include your own translations, you can do this by providing the "messageConfig" property in the module configuration:

./your-app/config/main.php

Remember that all the module translations are stored in the file jlorente/config.php

You can also use your own layout for the module views by setting the path in the layout property in the module configuration:

./your-app/config/main.php

Using the Variables in the code

The Variable model is the one that should be used to check the values of your configuration params. In order to do that use the static method value.

The returned value will be of the type of the variable.

Variables of TYPE_OBJECT type will return an instance of a stdObject class. Following the previous example, if I want to check the values of my 'CODE-OF-MY-TYPE_OBJECT-VARIABLE' variable I should do.

There is a shorthand method for changing value of variable instance.

Further considerations

Remember to bootstrap the Module if you want to extend the VariableController and preserve the provided translations. If you don't do it, the Module and the translation configuration will never be loaded.

If that is your case include:

./your-app/config/main.php

License

Copyright © 2015 José Lorente Martín [email protected].

Licensed under the MIT license. See LICENSE.txt for details.


All versions of yii2-config-variables with dependencies

PHP Build Version
Package Version
No informations.
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 jlorente/yii2-config-variables contains the following files

Loading the files please wait ....