Quantcast
Channel: Live News for Yii Framework
Viewing all 2943 articles
Browse latest View live

[news] Gii extension 2.2.0 released

$
0
0

We are very pleased to announce the release of Gii extension version 2.2.0.

This release adds support for via() junction relations in model generator.

See the CHANGELOG for details.


[news] Yii 2.0.34

$
0
0

We are very pleased to announce the release of Yii Framework version 2.0.34. Please refer to the instructions at https://www.yiiframework.com/download/ to install or upgrade to this version.

Version 2.0.34 is a minor release of Yii 2.0 that fixes regressions introduced by 2.0.33.

Thanks to all Yii community members who contribute to the framework, translators who keep documentation translations up to date and community members who answer questions at forums.

There are many active Yii communities so if you need help or want to share your experience, feel free to join them.

A complete list of changes can be found in the CHANGELOG.

[extension] olegbolden/yii2-show-n-pages

$
0
0

Page size selector widget (for DetailView, GridView etc.)

  1. Compatibility
  2. Installation
  3. Usage
  4. Options

By default there is no page size selector for Yii2 in multi page listings created with widgets like DetailView etc. This extension adds such a functionality in popular javascript DataTables-like style without jQuery.

The extension is simple to use and fully customizable to fit your page layout.

Compatibility

PHP version >=5.6
All modern browsers and IE.
Yii2 versions >=2.0.*

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist olegbolden/yii2-show-n-pages-widget "*"

or add

"olegbolden/yii2-show-n-pages-widget": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your View code by:

<?= \olegbolden\showNpages\widgets\PageSizeWidget::widget([options]); ?>

Actual page size for your data provider is available with the following call

$dataProvider = new ActiveDataProvider([
    'query' => $query,
    'pagination' => [
        'pageSize' => \olegbolden\showNpages\helpers\PageSizeStorage::getPageSize('statistics')
    ]
]);

where optional argument 'statistics' (default is 'main') specifies section identifier for the corresponding widget.

Options

The following options are available

lang

Language settings `php 'lang' => [

PageSizeWidget::LANG_SHOW    => 'Показать',
PageSizeWidget::LANG_ENTRIES => 'записей',
PageSizeWidget::LANG_ALL     => 'Все',

] `

section

Optional parameter to distinguish between widgets for different sections of your site to set independent page size settings for each. `php 'section' => 'statistics' `

pageSizes

Custom set of predefined page sizes in case you are not satisfied with the default one.

It is useful if you want to exclude option "all" among page sizes in case your data set is very big and there is no sense to show all items on the only page. `php 'pageSizes' => [10, 50, 100] `

wrapperClass / innerClass

Style classes for the widget to fit in your page.

For example, styles specified as `php 'wrapperClass' => 'pull-right', 'innerClass' => 'pageSelector' will give the following layouthtml

<span class="pageSelector">Show <select name="pageSize">
        <option value="10">10</option>
        ...
        <option value="1000000">All</option>
    </select> items</span>

`

[extension] gaxz/yii2-cron-manager

$
0
0

Cron Manager module for Yii2 framework

This is a simple and flexible module for creating\updating background tasks of cron application. It is designed to work with yii2 console controllers and description provides some advice to work with them.

Installation

Via composer

composer require --prefer-dist gaxz/yii2-cron-manager

or add to your composer.json

"gaxz/yii2-cron-manager": "*"

and

composer install 

Add the code below to your web and console config files:

'modules' => [
    'crontab' => [
    	'class' => 'gaxz\crontab\Module'
    ],
]

And finally

php yii migrate --migrationNamespaces=gaxz\\crontab\\migrations

Also make sure that cron is installed and running.

Configuration

Module requires a list of routes to yii2 console controllers. The list is used in gui to set up background tasks and form crontab lines. You can specify this by passing the controller classname with namespace into config file:

'source' => 'app\commands\HelloController' 

or an array

'source' => [
    'console\controllers\EmailController',
    'console\controllers\UserController',
],

Module will parse controllers and form list of routes. Excluding actions from list if needed:

'exclude' => [
	'/email/send'
],

or you can specify routes manually

'routes' => [
    '/console/email/send',
    '/console/user/proccess-order'
]

It is important to add "/" at the start to provide an absolute route. Don't forget to apply changes to both console and web configuration files.

Usage

Now you can manage background tasks in the module section of your application.

  1. Create Cron Task
  2. Add cron expression to schedule field
  3. Select a route from list

If your background task is using parameters you can add them as a json string in gui, then pass to controller action and decode.

public function actionTest($params)
{
    $params = json_decode($params, true);
    print $params['message'] . PHP_EOL;
    return ExitCode::OK;
}

It is important to use PHP_EOL to write readable output to logs. Also module is using ExitCode class to normalize return values and it's recommended to design your actions accordingly to ExitCode constants. You can use them in exceptions as well:

if (empty($model)) {
    throw new Exception('Unable to find model', ExitCode::DATAERR);
}

You don't need to try-catch exceptions since module is doing it by itself. This will form readable logs that are comfortable to support and search through.

Will be useful to check crontab file of php user to check if everything works correctly.

crontab -e -u www-data

Advanced configuration

Warning! Before you update settings that change crontab line (e.g phpBin, yiiBootstrapAlias, outputSetting), disable all of your active cron tasks.

Duplicating output to a file or STDOUT\STDERR:

'modules' => [
    'crontab' => [
    	'class' => 'gaxz\crontab\Module'
    	...
        'outputSetting' => '>> /var/log/app.log'
        ...
    ],
]

will form:

php yii /crontab/exec 1 >> /var/log/app.log 

Setting path to php binary file manually:

'phpBin' => '/usr/bin/php'

Writing configs of crontab file:

'headLines' => [
    'SHELL=/bin/sh',
    'PATH=/usr/bin:/usr/sbin',
],

Setting crontab username This will work only in case PHP script is running from privileged user (e.g. 'root')

'crontabUsername' => 'www-data',

Setting path to yii bootstrap file

'yiiBootstrapAlias' => '@app/yii'

[extension] hoaaah/yii2-ajaxcrud-bs4

$
0
0

yii2-ajaxcrud

  1. Features
  2. Installation
  3. Usage

This is not my work, this repository created by johitvn, but because I (and maybe some other people) need to optimize this Gii Template with BS4, so I create new repository to accomodate it. If johitvn already merge my PR, I will delete this repository.

Latest Stable Version License Total Downloads

Gii CRUD template for Single Page Ajax Administration for yii2

yii2 ajaxcrud extension screenshot

Features

  • Create, read, update, delete in onpage with Ajax
  • Bulk delete suport
  • Pjax widget suport
  • Export function(pdf,html,text,csv,excel,json)

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist hoaaah/yii2-ajaxcrud-bs4 "*"

or add

"hoaaah/yii2-ajaxcrud-bs4": "*"

to the require section of your composer.json file.

Usage

For first you must enable Gii module Read more about Gii code generation tool

Because this extension used kartik-v/yii2-grid extensions so we must config gridview module before

Let 's add into modules config in your main config file ``php 'modules' => [

'gridview' =>  [
    'class' => '\kartik\grid\Module'
]       

] ``

You can then access Gii through the following URL:

http://localhost/path/to/index.php?r=gii

and you can see Ajax CRUD Generator

Other Links Free download wordpress theme Free download html template

[extension] hoaaah/yii2-rest-api-template

$
0
0

yii2.png

Yii 2 REST API Template

  1. Yii2 REST API Template
  2. Supported Authentication
  3. Auth Scenario
  4. API versioning

Yii2 REST API Template

This is a a REST API TEMPLATE with Yii2. This template use Yii2-Micro approach so it will be lightweight and easy to deploy.

Installation

  1. Yii2 REST API Template
  2. Supported Authentication
  3. Auth Scenario
  4. API versioning

The preferred way to install this template is through composer.

Either run

composer create-project --prefer-dist hoaaah/yii2-rest-api-template [app_name]

Setup your database configuration from config/db.php. Create your database because this template will not create it for you :)

<?php
return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=your_db_name',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ],
    ],
];

Then run migration to create table in selected database.

yii migrate

Directory Structure

  1. Yii2 REST API Template
  2. Supported Authentication
  3. Auth Scenario
  4. API versioning

Since this template use MicroFramework approach, directory structure might be a little bit different from Yii2.

  config/             contains application configurations
  controllers/        contains Web controller classes
  migration/          contains list of your migration files
  models/             contains model classes
  modules/            contains your rest-api versioning (based on modules)
  vendor/             contains dependent 3rd-party packages
  web/                contains the entry script and Web resources

This template use modules as versioning pattern. Every version of API saved in a module. This template already have v1 module, so it means if consumer want to use v1 API, it can access https://your-api-url/v1/endpoint.

API Scenario

  1. Yii2 REST API Template
  2. Supported Authentication
  3. Auth Scenario
  4. API versioning

Supported Authentication

This template support 3 most used authentication. (Actually it's not me who make it, Yii2 already support it all :D ).

  1. HTTP Basic Auth: the access token is sent as the username. This should only be used when an access token can be safely stored on the API consumer side. For example, the API consumer is a program running on a server.
  2. Query parameter: the access token is sent as a query parameter in the API URL, e.g., https://example.com/users?access-token=xxxxxxxx. Because most Web servers will keep query parameters in server logs, this approach should be mainly used to serve JSONP requests which cannot use HTTP headers to send access tokens.
  3. OAuth 2: the access token is obtained by the consumer from an authorization server and sent to the API server via HTTP Bearer Tokens, according to the OAuth2 protocol.

Auth Scenario

This template already have basic endpoint that you can use to start your REST-API. Such as:

Endpoint Type Usage
https://YOUR-API-URL/ GETlist all post created
https://YOUR-API-URL/view?id={id} GETView a post
https://YOUR-API-URL/login POST Login with username and password
https://YOUR-API-URL/signup POST Signup with username, email and password
https://YOUR-API-URL/v1/post GET List all post created
https://YOUR-API-URL/v1/post/create POST Create a new post (title, body)
https://YOUR-API-URL/v1/post/update?id={id} PUT / PATCH Update a post (title, body)
https://YOUR-API-URL/v1/post/delete?id={id} DELETE Delete a post
https://YOUR-API-URL/v1/post/view?id={id} GET View a post

API versioning

This template give you versioning scenario based on module application. In Yii2 a module are self-contained software units that consist of model, views, controllers and other supporting components. This template already have v1 module, it means all of endpoint for API v1 created in this module. When you publish a new API version (that break backward compatibility / BBC), you can create a new module. For more information create a module, you can visit this Yii2 Guide on Creating Module.

TODO

  1. Yii2 REST API Template
  2. Supported Authentication
  3. Auth Scenario
  4. API versioning

Feel free to contribute if you have any idea.

  • [x] Rest API Template
  • [x] Login and signup in SiteController
  • [x] Example of versioning and Blog Scenario
  • [ ] Authentication Type from params
  • [ ] Rate Limiter from params
  • [ ] Change auth_key for every login
  • [ ] Auth_key have expiration
  • [ ] each auth_key have application token

Creator

  1. Yii2 REST API Template
  2. Supported Authentication
  3. Auth Scenario
  4. API versioning

This Template was created by and is maintained by Heru Arief Wijaya.

[extension] hoaaah/yii2-startbootstrap-sb-admin-2-asset

$
0
0

yii2-startbootstrap-sb-admin-2-asset

  1. Preview
  2. Requirement
  3. Installation
  4. Usage
  5. Menu Widget
  6. Card Widget
  7. TODO
  8. Creator

This packages contans an Asset Bundle of Startbootstrap SB Admin 2 for Yii2.

Startbootstrap SB Admin 2 is a responsive Bootstrap 4 created by Start Bootstrap.

Preview

SB Admin 2 Preview

Launch Live Preview

Start Bootstrap was created by and is maintained by David Miller, Owner of Blackrock Digital.

Start Bootstrap is based on the Bootstrap framework created by Mark Otto and Jacob Thorton.

Requirement

This Asset Bundle need Bootstrap 4. Since Yii2 used Bootstrap 3 by default, you must install and change every Bootstrap 3 Asset to Bootstrap 4. You can read this tutorial to migrate to Yii2 Bootstrap 4 :

Installation

The preferred way to install this extension is through composer.

Either run

composer require hoaaah/yii2-startbootstrap-sb-admin-2-asset:dev-master

or add

"hoaaah/yii2-startbootstrap-sb-admin-2-asset": "*"

to the require section of your composer.json file.

Usage

You can see views-examples folder for example use of this library

Menu Widget

You can use Menu widget in your sidebar. This widget optimize for Startbootstrap SB-Admin 2 template. This widget, like SB-Admin 2, only support 2 level menu.

You can see example use of this widget in views-exampale/views/layout/sidebar.php. `php use hoaaah\sbadmin2\widgets\Menu; echo Menu::widget([

'options' => [
    'ulClass' => "navbar-nav bg-gradient-primary sidebar sidebar-dark accordion",
    'ulId' => "accordionSidebar"
], //  optional
'brand' => [
    'url' => ['/'],
    'content' => <<<HTML
        <div class="sidebar-brand-icon rotate-n-15">
        <i class="fas fa-laugh-wink"></i>
        </div>
        <div class="sidebar-brand-text mx-3">SB Admin <sup>2</sup></div>        

HTML

],
'items' => [
    [
        'label' => 'Menu 1',
        'url' => ['/menu1'], //  Array format of Url to, will be not used if have an items
        'icon' => 'fas fa-fw fa-tachometer-alt', // optional, default to "fa fa-circle-o
        'visible' => true, // optional, default to true
        // 'options' => [
        //     'liClass' => 'nav-item',
        // ] // optional
    ],
    [
        'type' => 'divider', // divider or sidebar, if not set then link menu
        // 'label' => '', // if sidebar we will set this, if divider then no
    ],
    [
        'label' => 'Menu 2',
        // 'icon' => 'fa fa-menu', // optional, default to "fa fa-circle-o
        'visible' => true, // optional, default to true
        // 'subMenuTitle' => 'Menu 2 Item', // optional only when have submenutitle, if not exist will not have subMenuTitle
        'items' => [
            [
                'label' => 'Menu 2 Sub 1',
                'url' => ['/menu21'], //  Array format of Url to, will be not used if have an items
            ],
            [
                'label' => 'Menu 2 Sub 2',
                'url' => ['/menu22'], //  Array format of Url to, will be not used if have an items
            ],
        ]
    ],

    [
        'label' => 'Menu 3',
        'visible' => true, // optional, default to true
        // 'subMenuTitle' => 'Menu 3 Item', // optional only when have submenutitle, if not exist will not have subMenuTitle
        'items' => [
            [
                'label' => 'Menu 3 Sub 1',
                'url' => ['/menu21'], //  Array format of Url to, will be not used if have an items
            ],
            [
                'label' => 'Menu 3 Sub 2',
                'url' => ['/menu22'], //  Array format of Url to, will be not used if have an items
                'linkOptions' => [
                   'onClick' => 'alert("This is onClick")',
                ]
            ],
        ]
    ],
]

]); ` As you can see in above example, this Widget consist of two primary method.

Method Explanation
options Optional method. in this metod you will set any costumization of this Menu widget. It consist of ulClass method and ulId method
-- ulClass Set your <ul> class of this menu. default to "navbar-nav bg-gradient-primary sidebar sidebar-dark accordion"
-- ulId Set your <ul> id of this menu. default to "accordionSidebar"
items Required method. You must set this method in your widget. You can set items inside this method and it will create sub-menu items. Items and Sub Menu Item method use the same method, except for type method.
-- type Optional parameter, there are 3 category in this params. They are menu, divider, and sidebar. Default value of this params are menu
-- label Required parameter. This param will give label to your menu
-- icon Optional parameter. Will use font-awesome icon, so the value of this param will use fa class. Default to fas fa-circle
-- url Required parameter. Use Array value, like array on \yii\helpers\Url::to($array). If there are items parameter set, url will be ignored
-- visible Optional paremeter. Determined the visibility of menu. Value of visible are boolean. Default to true
-- linkOptions Optional paremeter. This param use array, give any options param to a tag, such as onClick or other options in link.

Card Widget

You can use card widget. This widget will create bootstrap card, optimize for this template

Example use of card are like below code `php use hoaaah\sbadmin2\widgets\Card; echo Card::widget([

'type' => 'cardBorder',
'label' => 'Label',
'sLabel' => '1000',
'icon' => 'fas fa-calendar',
'options' => [
    'colSizeClass' => 'col-md-3',
    'borderColor' => 'primary',
]

]); ` As you can see in above example, this Widget consist of some method.

Method Explanation
type Optional method. In this method you set type of your card. This widget support this type of card: cardBorder, ..... Default value of type is cardBorder
label Required method. In this method you set primary label of your card
sLabel Required method. In this method you set secondary label of your card
icon Required method. In this method you set icon of your card
options options method. Set options, available options are colSizeClass, borderColor
-- colSizeClass Set your col-size, value of this method are bootstrap col-size
-- borderColor Set your borderColor, value of this method are bootstrap color

TODO

Todo Widget

  • [x] Menu
  • [x] CardBorder
  • [x] CardBox
  • [ ] HeaderMenu
  • [ ] HeaderColor based on Params
  • [ ] Etc

Creator

This asset wrapper was created by and is maintained by hoaaah.

[extension] roopz/yii2-imap

$
0
0

yii2 Imap

This library can be used to read mails from IMAP server using PHP and Yii2.

Installation by composer

{
    "require": {
       "roopz/yii2-imap": "dev-master"
    }
}

Or

$ composer require roopz/yii2-imap "dev-master"

Documentation

Documentation, Usage and Demo

Config example
'imap' => [
    'class' => '',
    'connection' => [
        'imapPath' => '',
        'imapLogin' => '',
        'imapPassword' => '',
        'serverEncoding' => 'utf-8',
        'searchEncoding' => 'US-ASCII',//MIME character set to use when searching strings. Not mandatory
        'attachmentsDir' => '/tmp',
        'decodeMimeStr' => false
    ]
]

Donate

[Send me a beer] (https://donorbox.org/yii2-imap)

Contribute

Feel free to contribute. If you have ideas for examples, add them to the repo and send in a pull request.

Apreciate

Dont forgett o Leave me a "star" if you like it. Enjoy coding!


[extension] itechsolution

$
0
0
  1. Requirements
  2. Installation
  3. Usage
  4. Resources

...overview of the extension...

Requirements

...requirements of using this extension (e.g. Yii 2.0 or above)...

Installation

...how to install the extension (e.g. composer install extensionname)...

Usage

...how to use this extension...

...can use code blocks like the following...

$model=new User;
$model->save();

Resources

DELETE THIS SECTION IF YOU DO NOT HAVE IT

...external resources for this extension...

  • [Project page](URL to your project page)
  • [Try out a demo](URL to your project demo page) ITech solutions is one of the most renown seo, Digital Marketing company located in Canada.Providing SEO services wordwide http://theitechsolutions.com/[]()

[extension] mgrechanik/yii2-seo-categories

$
0
0

Active Record hierarchical SEO categories and tags for Yii2 framework

  1. Table of contents
  2. Goal
  3. or `slug` fields and they will not appear in the web form of creating/editing SEO category
  4. Installing

Русская версия

Table of contents

Goal

This extension gives you a variation of categories module, in which the opportunity to create any your own `Active Record` category models was given.

We suggest that when creating pages at frontend to display associated content of the category (or tag) we would need to manage SEO information of such category page.

Respectively we add next fields to our SEO category `Active Record` model:

  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    

With all this in module's settings you may choose not to use `meta_other`

or `slug` fields and they will not appear in the web form of creating/editing SEO category

Installing

Installing through composer:

The preferred way to install this extension is through composer.:

Either run composer require --prefer-dist mgrechanik/yii2-seo-categories

or add "mgrechanik/yii2-seo-categories" : "~1.0.0" to the require section of your composer.json

Migrations

This extension comes with two migrations:

  • the first creates SEO categories table with all indexes needed
  • the second creates unique index for `slug` field

You can run both of them:

php yii migrate --migrationPath=@vendor/mgrechanik/yii2-seo-categories/src/console/migrations

, or when you do not use `slug` field run only the first migration:

php yii migrate 1 --migrationPath=@vendor/mgrechanik/yii2-seo-categories/src/console/migrations
Setting the module up

As was mentioned in the basic categories module, this module follows the approach of universal module, and since it gives you only backend pages when you set it up into your application specify the next `mode:php

'modules' => [
    'seocategory' => [
        'class' => 'mgrechanik\yii2seocategory\Module',
        'mode' => 'backend',
        // Other module settings
    ],
    // ...
],

Done. When you access ```/seocategory``` page you will see all your SEO categories in a form of tree.

---

## Module settings <span id="settings"></span>

[Setting up](#setup) the module into application, along with all properties of the [base categories module](https://github.com/mgrechanik/yii2-categories-and-tags#settings), we can use it's next properties:

#### ```$useMetaOtherField = false``` 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Whether to use ```other meta tags``` field

#### ```$useSlugField = true``` 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Whether to use ```slug``` field. It is supposed to be unique

#### ```$slugPattern``` 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- When we use previous field in this property we set up regular expression of expected symbols 

#### ```$showTitleColumnAtIndexPage = true```
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Whether to display ```title``` field in the categories list grid

#### ```$showSlugColumnAtIndexPage = false``` 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Whether to display ```slug``` field in the categories list grid

[news] Yii 2 Composer Installer 2.0.9

[extension] ahmadasjad/yii2-widgets

$
0
0

yii2-widgets

Plus-Minus-Input

Installation
composer require ahmadasjad/yii2-widgets
Usage Example
<?php
echo \ahmadasjad\yii2Widgets\PlusMinusInput::widget([
    'name' => 'name_test',
    'plugin_options' => ['parser'=>'parseFloat', 'step'=>0.5]
]);
?>

Options to customize the plugin in plugin_options param:

[
    'val_min' => 0,
    'val_max' => 1000,
    'step' => 1,
    'parser' => 'parseInt',
    'container' => ['class' => 'input-group', 'id' => 'your-custom-id-container'],
    'plus' => ['id' => 'your-custom-id-plus', 'class' => 'btn btn-success', 'label' => '+',],
    'minus' => ['id' => 'your-custom-id-minus', 'class' => 'btn btn-danger', 'label' => '-',],
]

val_min Minimum value allowed for input

val_max Maximum value allowed for input

step How much value to be increased/decreased on press of plus/minus button

parser Javascript function to parse the input data. For example parseInt, parseFloat, etc.

plus configuration for plus button minus configuration for plus button

[extension] hail812/yii2-adminlte3

$
0
0

hail812/yii2-adminlte3

  1. Installation
  2. Usage
  3. AdminLTE Plugins

adminlte3 for yii2

home

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist hail812/yii2-adminlte3 "*"

or add

"hail812/yii2-adminlte3": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, you can config the path mappings of the view component:

'components' => [
    'view' => [
         'theme' => [
             'pathMap' => [
                '@app/views' => '@vendor/hail812/yii2-adminlte3/src/views'
             ],
         ],
    ],
],

Copy files from @vendor/hail812/yii2-adminlte3/src/views to @app/views, then edit.

simply use:

<?= \hail812\adminlte3\widgets\Alert::widget([
    'type' => 'success',
    'body' => '<h3>Congratulations!</h3>'
]) ?>

AdminLTE Plugins

AdminLTE Plugins are not included in AdminLteAsset, if you want to use any of them you can add it dynamically with PluginAsset. For example:

/* @var $this \yii\web\View */

\hail812\adminlte3\assets\PluginAsset::register($this)->add('sweetalert2');

before this, maybe you should edit params.php:

return [
    'adminEmail' => 'admin@example.com',
    'hail812/yii2-adminlte3' => [
        'pluginMap' => [
            'sweetalert2' => [
                'css' => 'sweetalert2-theme-bootstrap-4/bootstrap-4.min.css',
                'js' => 'sweetalert2/sweetalert2.min.js'
            ]
        ]
    ]
];

or

/* @var $this \yii\web\View */

$bundle = \hail812\adminlte3\assets\PluginAsset::register($this);
$bundle->css[] = 'sweetalert2-theme-bootstrap-4/bootstrap-4.min.css';
$bundle->js[] = 'sweetalert2/sweetalert2.min.js';

[extension] djidji/yii2-default-url-rule

$
0
0

UrlRule for default basic logic in parsing and creating pretty Url.

  1. Conventions
  2. Installation
  3. Usage
  4. Examples

Parsing and creating url with arguments pretified as well instead of in query string format. Route and argument segments of url are separated by the UrlManager->routeParam

Conventions

  1. Argument is prettified only if its name is declared as action method parameter otherwise it stay in query string format;

  2. Arguments are orderer by the way corresponding action method parameters are declared;

  3. Optional Argument nth binds to its corresponding action method parameter only if all arguments --nth are explicitly passed. --nth argments are inserted at their respective places in created url if were nor explicit;

  4. Arguments less than required or more than action method parameters show 404

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist djidji/yii2-default-url-rule "*"

or add

"djidji/yii2-default-url-rule": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by declaring in rules of Urlmanager :

'rules' => [
    // ...other url rules...
    [
        'class' => 'djidji\DefaultUrlRule',
        // complete file path to save routes.
        'routesFile' => '@app/config/routes.php'
    ],
]

Examples

class PostController extends Controller
{
    public function actionIndex($category,$year=2015,$tag='')
    {

    }
    public function actionView($id)
    {

    }
}
To create Url
  • Url::to(['post/index', 'year' => 2014, 'category' => 'php']) creates /index.php/post/index/r/php/2014 ;

  • Url::to(['post/index', 'category' => 'php']) creates /index.php/post/index/r/php;

  • Url::to(['post/index', 'category' => 'php','tag'=>'programming']) creates /index.php/post/index/r/php/2015/programming. default value of parameter 'year' is inserted at its place;

  • Url::to(['post/index','year' => 2014]) result to false because the argument for required $category parameter is not passed;

  • Url::to(['post/view', 'id' => 100]) creates /index.php/post/view/r/100 ;

  • Url::to(['post/view', 'id' => 100, 'source' => 'ad']) creates creates /index.php/post/view/r/100?source=ad. Because "source" argument is not declared as actionView methoth, it is appended as a query parameter in the created URL.

To parse Url
  • /index.php/post/index result to false because actionIndex has required firs parameter that need argments to be passed.

  • /index.php/post/index/r/php is parsed to ['post/index', ['category' => 'php']] ;

  • /index.php/post/index/r/php/2015/programming is parsed to ['post/index', ['category' => 'php','tag'=>'programming','year'=>2015]] ;

  • /index.php/post/index/r/php/programming is parsed to ['post/index', ['category' => 'php','year'=>'programming']] ;

  • /index.php/post/view/r/100?source=ad is parsed to ['post/view', ['id' => 100]];

  • /index.php/post/view/r/100/ad?source=ad result to false because actionView method expect one argment instead of two.

[news] Yii 2.0.35

$
0
0

We are very pleased to announce the release of Yii Framework version 2.0.35. Please refer to the instructions at https://www.yiiframework.com/download/ to install or upgrade to this version.

Version 2.0.35 fixes 13 issues and adds some small enhancements:

  • Query::withQuery() method that can be used for CTE.
  • yii\i18n\Formatter::$currencyDecimalSeparator to allow setting custom symbols for currency decimal in IntlNumberFormatter.
  • SameSite for cookies now works on PHP < 7.3.
  • jQuery 3.5.0 can now be used.

Thanks to all Yii community members who contribute to the framework, translators who keep documentation translations up to date and community members who answer questions at forums.

There are many active Yii communities so if you need help or want to share your experience, feel free to join them.

A complete list of changes can be found in the CHANGELOG.


[news] Shell extension 2.0.4 released

$
0
0

We are very pleased to announce the release of Shell extension version 2.0.4. This version allows installing psy/psysh ~0.10.3.

[news] ApiDoc extension version 2.1.4 released

$
0
0

We are very pleased to announce the release of the ApiDoc extension version 2.1.4.

This release add support for @property and @method annotations.

See the CHANGELOG for a full list of changes.

[news] Gii extension 2.2.1 released

$
0
0

We are very pleased to announce the release of Gii extension version 2.2.1.

This release allows the usage of anonymous generators.

See the CHANGELOG for details.

[news] Redis extension 2.0.13 released

[news] Injector 1.0.0 released

$
0
0

Injector can invoke methods or create objects resolving their dependencies from a PSR-11 container via autowiring. It can:

  • Invoke callable or create an object of a given class.
  • Resolve dependencies by parameter types using the given PSR-11 container.
  • Pass concrete dependency instances by type.
  • Pass arguments by name.

As one of the central parts of Yii 3 it is what does all the auto-wiring into action handlers and widgets.

Since is a framework-independent package, it can be used in any PHP project.

Check it out

Viewing all 2943 articles
Browse latest View live


Latest Images