Download the PHP package cinghie/yii2-traits without Composer

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

Yii2 Traits

License Latest Stable Version Latest Release Date Latest Commit Total Downloads

Yii2 Traits is a library of reusable traits designed to reduce duplicated code across Yii2 modules. It provides shared model attributes, validation rules and labels, UI helpers, attachment/media helpers, hierarchy and ordering helpers, cache actions, user helpers and other common functionality.

Requirements

cinghie/yii2-traits is a shared runtime foundation for other Cinghie modules. Integrations used by its traits are therefore required Composer dependencies and are installed automatically with the package.

Required runtime dependencies

Package Used for
2amigos/yii2-ckeditor-widget CKEditor support in EditorTrait
2amigos/yii2-taggable-behavior TaggableTrait
2amigos/yii2-tinymce-widget TinyMCE support in EditorTrait
cinghie/yii2-user-extended User helper integrations
cocur/slugify Slug generation in NameAliasTrait and TitleAliasTrait
dektrium/yii2-user User relations in CreatedTrait, ModifiedTrait and UserTrait
google/cloud-translate Google Cloud Translation V3 in GoogleTranslateTrait
james-heinrich/getid3 Attachment and media metadata
kartik-v/yii2-detail-view DetailView helpers
kartik-v/yii2-helpers Kartik HTML helpers
kartik-v/yii2-markdown Markdown editor support
kartik-v/yii2-mpdf PDFTrait
kartik-v/yii2-social SocialTrait
kartik-v/yii2-widgets Form widgets such as Select2, DateTimePicker and FileInput
php-ffmpeg/php-ffmpeg Video thumbnail generation
vova07/yii2-imperavi-widget Imperavi support in EditorTrait

Some required integrations are legacy or abandoned upstream. They remain part of the runtime contract for compatibility with Cinghie modules and should be migrated in a future compatibility effort.

Installation

Install the package with Composer:

Composer installs the complete runtime dependency set automatically.

Configuration

Translations

Add the translation source to your application configuration:

Runtime configuration

Attachment paths, editor selection, FFmpeg binaries and Google Translate settings can be supplied through Yii::$app->params['yii2Traits'] or an equivalent host getTraitsConfig() configuration. Legacy module-level values remain supported where applicable.

GoogleTranslateTrait uses Google Cloud Translation V3 and Application Default Credentials (ADC). Configure credentials in the runtime environment, for example with GOOGLE_APPLICATION_CREDENTIALS. The legacy $apiKey method argument is retained for API compatibility and is not used for V3 authentication.

If Markdown support from EditorTrait is used, configure the Kartik Markdown module:

No Kartik Grid module is required by yii2-traits itself.

Usage

Model rules and labels

Trait rules and labels follow Yii2's instance-method contract. Merge trait-specific helpers from the model's rules() and attributeLabels() methods:

Do not call trait rules() or attributeLabels() statically. Model-facing traits expose get*Rules() and get*AttributeLabels() helpers for composition.

Trait methods can then be called like normal model methods:

Security and behavioral notes

AttachmentTrait

Attachment deletion is constrained to the configured attachment directory. Generated attachment filenames use secure random values while the legacy generateMd5FileName() method name is preserved for backward compatibility. Configure FFmpeg/FFprobe paths explicitly when media thumbnail generation is used.

CacheTrait

Cache mutation actions are administrative operations. They require POST requests, the configured cache-management authorization and CSRF validation. Applications should not disable CSRF validation on controllers exposing these actions.

OrderingTrait

Ordering updates run transactionally. Move-to-last operations calculate the scoped maximum inside the transaction, and the supplied ActiveRecord class is checked for compatibility with the host model.

ParentTrait

getParent() returns the direct parent. getParents() and getAncestors() represent the ancestor chain, nearest parent first. Validation prevents missing parents, self-parenting and hierarchy cycles.

Traits reference

AccessTrait

Access-state model and UI helpers.

AddressTrait

Address fields and geocoding helpers.

AttachmentTrait

Attachment metadata, filesystem, widget and media helpers. Kartik widgets, getID3 and PHP-FFMpeg are installed as runtime dependencies.

CacheTrait

Cache inspection and administrative invalidation actions.

CreatedTrait

Creation timestamp/user audit helpers.

EditorTrait

Editor selection and rendering facade. CKEditor, TinyMCE, Imperavi and Markdown integrations are installed automatically.

GoogleTranslateTrait

Google Cloud Translation V3 integration.

ImageTrait

Image metadata and UI helpers.

LanguageTrait

Language model and selection helpers.

ModifiedTrait

Modification timestamp/user audit helpers.

NameAliasTrait

Name and slug/alias helpers.

OrderingTrait

Transactional ordering helpers.

ParentTrait

Parent relation, hierarchy validation and ancestor traversal.

PDFTrait

PDF integration backed by the required Kartik mPDF package.

SeoTrait

SEO metadata and robots helpers.

SequentialTrait

Sequential code generation helper.

SocialTrait

Social integration helpers backed by the required Kartik Social package.

StateTrait

Active/inactive state helpers and UI integration.

TaggableTrait

Tag behavior helpers.

TitleAliasTrait

Title and slug/alias helpers.

UserHelpersTrait

Helpers for the current user, profiles, roles and selectable users.

UserTrait

User relation and UI helpers.

VideoTrait

Video metadata and UI helpers.

ViewsHelperTrait

Common view and action-button helpers.

Compatibility notes

Testing

The project CI validates PHP 8.1 through PHP 8.5 with Composer validation, dependency installation and audit, PHP syntax checks, PHPUnit, standalone smoke tests and required-runtime dependency smoke tests.


All versions of yii2-traits with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
yiisoft/yii2 Version ^2.0.55
2amigos/yii2-ckeditor-widget Version ^2.2.0
2amigos/yii2-taggable-behavior Version ^1.0.2
2amigos/yii2-tinymce-widget Version ^1.1.3
cinghie/yii2-user-extended Version ^0.6.3
cocur/slugify Version ^4.7.1
dektrium/yii2-user Version ^0.9.14
google/cloud-translate Version ^2.3.3
james-heinrich/getid3 Version ^1.9.25
kartik-v/yii2-detail-view Version ^1.8.7
kartik-v/yii2-helpers Version ^1.3.9
kartik-v/yii2-markdown Version ^1.3.1
kartik-v/yii2-mpdf Version ^1.0.6
kartik-v/yii2-social Version ^1.3.5
kartik-v/yii2-widgets Version ^3.4.1
php-ffmpeg/php-ffmpeg Version 0.19 || ^1.4.0
vova07/yii2-imperavi-widget Version ^2.0.11
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 cinghie/yii2-traits contains the following files

Loading the files please wait ...