Download the PHP package sjaakp/yii2-taggable without Composer

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

yii2-taggable

Manage tags of ActiveRecords in PHP-framework Yii 2.0

Latest Stable Version Total Downloads License

This package contains five classes to handle the tagging of ActiveRecords with keywords or similar. The tags can be associated with or decoupled from a model (ActiveRecord), and can be sorted. Tags are manipulated with the excellent jQuery tagEditor developed by Pixabay.

The four main classes of yii2-taggable are:

There is also a class TagEditorAsset, which is a helper class for TagEditor.

A demonstration of the yii2-taggable suit is here.

Notice that the API for version 2 is slightly different from that of version 1.

Installation

The preferred way to install yii2-taggable is through Composer. Either add the following to the require section of your composer.json file:

"sjaakp/yii2-taggable": "*"

Or run:

composer require sjaakp/yii2-taggable "*"

You can manually install yii2-taggable by downloading the source in ZIP-format.

Setup

Suppose we have a class (ActiveRecord) Article of articles which can be tagged, and another class Tag to hold the tags.

Tag has at least the following attributes:

Junction table

Article and Tag are linked with a junction table in a many-to-many relation. Let's call the table article_tag. It has the following fields:

The junction table doesn't need to have a primary key. It's a good idea to set indexes on both model_id and tag_id.

TaggableBehavior

The class Article is taggable, and should be set up like this:

<!-- Display article title and body here. -->

<h4>Tags</h4>
<p><?= $model->tagLinks ?></p>

tagLinks is a new virtual attribute, added to Article by TaggableBehavior.

All the Tags can be retrieved with:

$allTags = $article->tagModels;

To get an ActiveQuery, for instance to use in an ActiveDataProvider, use:

$provider = new ActiveDataProvider([
    'query' => $article->getTagModels()
]);

If you want to know whether an Article has a Tag with a certain name, say 'politics', you can query the class like so:

if ($article->hasTag('politics'))   {
    // ...
}

Article update

To make creating and updating Tags easy, we also have to set up TagController:

    ...

    <?= $form->field($model, 'tags')->widget(TagEditor::class, [
        'clientOptions' => [
            'autocomplete' => [
                'source' => Url::toRoute(['tag/suggest'])
            ],
        ]
    ]) ?>
    ...

tags is also a new virtual attribute of Article, added to it by TaggableBehavior. 'tag/suggest' is the base of the route to the suggest action in TagController, which we defined before. Learn more about the clientOptions from Pixabay.

Modifications

The basic setup of yii2-taggable can be modified in a number of ways. Refer to the source files to see which other options are available. Some are:


All versions of yii2-taggable with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
yiisoft/yii2-jui Version *
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 sjaakp/yii2-taggable contains the following files

Loading the files please wait ....