Download the PHP package abahrami13/yii2-facades without Composer

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

yii2-facades

Facades support for Yii 2 application components & classes like Laravel

🟡 Installation

Step 1

Run composer require abahrami13/yii2-facades command.

Step 2

Add abahrami13\facades\RegisterFacadeAutoloader to the bootstrap array in the configuration file (config/web.php in the basic template).

🟡 Usage

🔷 Components facades namespaces

1) Yii2 Components

To use component facade, just import a class started with facades\ followed by the component id. For example for using facade of request component just import facades\Request:

use facades\Request;

2) Other Classes

To use facade for other classes, just add facades\ to the start of the class namespace.

For example, for using facade for the app\models\LoginForm class, just import facades\app\models\LoginForm class

🔷 Utilizing Facades

Just call the desired method statically & enjoy :)

For components:

Request::get('foo') is equal to Yii::$app->request->get('foo')

For other classes

LoginForm::rules()

is equal to

$loginForm = new LoginForm();

$loginForm->rules()

🟡 More Examples

🔷 Facades for Yii2 Components

🔸 Generate random string

before

$random = Yii::$app->security->generateRandomString(128);

after

import: use facades\Security;

$random = Security::generateRandomString(128);

🔸 Add Flash to session

before

Yii::$app->session->addFlash('success', 'Wow, Yii is great');

after

import: use facades\Session;

Session::addFlash('success', 'Wow, Yii is great');

🔸 Fetch all users

before

Yii::$app->db->createCommand('SELECT * FROM user')->queryAll();

after

import: use facades\Db;

Db::createCommand('SELECT * FROM user')->queryAll();

🔸 Format currency

before

Yii::$app->formatter->asCurrency(123456.78, 'USD');

after

import: use facades\Formatter;

Formatter::asCurrency(123456.78, 'USD');

🔷 Facades for other classes

🔸 Call none static methods on other classes

before

import: use app\classes\Greeting;

$obj = new Greeting();

$obj->sayHello('Mr. Mahan');

after

import: use facades\app\classes\Greeting;

Greeting::sayHello('Mr. Mahan');

🔸 Call none static methods on a model

before

import: use app\models\Post;

$post = new Post();

$titleLabel = $post->getAttributeLabel('title');

after

import: use facades\app\models\Post;

$titleLabel = Post::getAttributeLabel('title');

🟡 Available Facades


All versions of yii2-facades with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ~2.0.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 abahrami13/yii2-facades contains the following files

Loading the files please wait ....