yii2: working with yii2-sitemap-module - php

i used https://github.com/himiklab/yii2-sitemap-module in my yii2 project
this is my console :
return [
'id' => 'basic-console',
'language' => 'fa-IR',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log', 'gii'],
'controllerNamespace' => 'app\commands',
'modules' => [
'gii' => 'yii\gii\Module',
'user' => [
'class' => 'dektrium\user\Module',
'sourceLanguage' => 'en-US',
'languages' => 'fa-IR'
],
'sitemap' => [
'class' => 'himiklab\sitemap\Sitemap',
'models' => [
// your models
'app\modules\news\models\News',
// or configuration for creating a behavior
[
'class' => 'app\modules\news\models\News',
'behaviors' => [
'sitemap' => [
'class' => SitemapBehavior::className(),
'scope' => function ($model) {
/** #var \yii\db\ActiveQuery $model */
$model->select(['url', 'lastmod']);
$model->andWhere(['is_deleted' => 0]);
},
'dataClosure' => function ($model) {
/** #var self $model */
return [
'loc' => Url::to($model->url, true),
'lastmod' => strtotime($model->lastmod),
'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.8
];
}
],
],
],
],
'urls' => [
// your additional urls
[
'loc' => '/news/all',
'changefreq' => \himiklab\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.8,
'news' => [
'publication' => [
'name' => 'Example Blog',
'language' => 'fa',
],
'access' => 'Subscription',
'genres' => 'Blog, UserGenerated',
'publication_date' => 'YYYY-MM-DDThh:mm:ssTZD',
'title' => 'Example Title',
'keywords' => 'example, keywords, comma-separated',
'stock_tickers' => 'NASDAQ:A, NASDAQ:B',
],
'images' => [
[
'loc' => 'http://example.com/image.jpg',
'caption' => 'This is an example of a caption of an image',
'geo_location' => 'City, State',
'title' => 'Example image',
'license' => 'http://example.com/license',
],
],
],
],
'enableGzip' => true, // default is false
'cacheExpire' => 1, // 1 second. Default is 24 hours
],
],
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
],
'params' => $params,
];
this is my web.php:
'urlManager' => [
'enablePrettyUrl' => TRUE,
'showScriptName' => TRUE,
'enableStrictParsing' => FALSE,
'rules' => [
['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'],
// ...
],
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'salt',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
this is my news controller :
use himiklab\sitemap\behaviors\SitemapBehavior;
public function behaviors() {
return [
'sitemap' => [
'class' => SitemapBehavior::className(),
'scope' => function ($model) {
/** #var \yii\db\ActiveQuery $model */
$model->select(['id']);
// $model->andWhere(['is_deleted' => 0]);
},
'dataClosure' => function ($model) {
/** #var self $model */
return [
'loc' => Url::to($model->url, true),
'lastmod' => strtotime($model->lastmod),
'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => 0.8
];
}
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['get'],
],
],
];
}
Where is my xml file(url)??
What change should I do in my code?

If your controller (sitemap/default/index) is work well.
Your sitemap must be created in root directory via sitemap.xml file name, and accessible from http://your-domain/sitemap.xml URL.
For change it refer to this your code:
'rules' => [
['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'],
],

A shorter version of the routing that you can use:
'rules' => [
'sitemap.xml' => 'sitemap/default/index',
And relative to this route url in web: http://website/sitemap.xml
However, you can generate a sitemap without any extensions, which simplifies your work and does not need to understand other people's code. To do this, simply create the controller as in my working example:
<?php
namespace frontend\controllers;
use frontend\models\blog\articles\BlogArticles;
use frontend\models\blog\categories\BlogCategories;
use frontend\models\blog\series\BlogSeries;
use frontend\models\blog\tags\BlogTags;
use yii\web\Controller;
use yii\db\Query;
use Yii;
class SitemapController extends Controller
{
public function actionIndex()
{
//if You want delete cache
// Yii::$app->cache->delete('sitemap');
if (!$xml_sitemap = Yii::$app->cache->get('sitemap')) { // if has cache sitemap
$urls = array();
// all my categories
$articles = BlogArticles::find()->active()->orderCreatedAt()->all();
foreach ($articles as $article) {
$urls[] = array(
'loc' => $article->url,
'lastmod' => date( DATE_W3C, strtotime($article->lastMod) ),
'changefreq' => 'daily',
'priority' => 1.0
);
}
$categories = BlogCategories::find()->orderId()->all();
foreach ($categories as $category) {
$urls[] = array(
'loc' => $category->url,
'changefreq' => 'weekly',
'priority' => 0.8
);
}
$series = BlogSeries::find()->orderId()->all();
foreach ($series as $sery) {
$urls[] = array(
'loc' => $sery->url,
'changefreq' => 'weekly',
'priority' => 0.5
);
}
$tags = BlogTags::find()->orderId()->all();
foreach ($tags as $tag) {
$urls[] = array(
'loc' => $tag->url,
'changefreq' => 'weekly',
'priority' => 0.4
);
}
$xml_sitemap = $this->renderPartial('index', array(
'host' => Yii::$app->request->hostInfo, // your current domain
'urls' => $urls, // с generate urls for sitemap
));
Yii::$app->cache->set('sitemap', $xml_sitemap, 60*60*12); //cache 12 h
}
Yii::$app->response->format = \yii\web\Response::FORMAT_XML;
echo $xml_sitemap;
}
}
And You can see result in live site: https://coderius.biz.ua/sitemap.xml

Related

Yii2: yii\web\UrlManager does'nt make user-friendly urls

Here's urlManager configs:
return [
'class' => \yii\web\UrlManager::class,
'enablePrettyUrl' => true,
'showScriptName' => false,
'baseUrl' => '',
'rules' => [
'page/<id:[\\w-_]+>' => 'page/index',
],
];
Here's urlManager using:
$menuItems = [
[
'label' => 'Home',
'url' => Yii::$app->urlManager->createAbsoluteUrl(['/page']),
],
[
'label' => 'About',
'url' => Yii::$app->urlManager->createAbsoluteUrl(['/page', 'id' => 'about']),
],
[
'label' => 'Contact',
'url' => Yii::$app->urlManager->createAbsoluteUrl(['/page', 'id' => 'contact']),
],
];
And here's results from browser:
http://localhost/page?id=about
http://localhost/page?id=contact
What's wrong in my code?
You need to use exact route when creating URLs:
$menuItems = [
[
'label' => 'Home',
'url' => Yii::$app->urlManager->createAbsoluteUrl(['/page']),
],
[
'label' => 'About',
'url' => Yii::$app->urlManager->createAbsoluteUrl(['/page/index', 'id' => 'about']),
],
[
'label' => 'Contact',
'url' => Yii::$app->urlManager->createAbsoluteUrl(['/page/index', 'id' => 'contact']),
],
];

Failed to Insert Data with zend-form

I have a mode named Album as follows:
namespace Album\Model;
// Add the following import statements:
use DomainException;
use Zend\Filter\StringTrim;
use Zend\Filter\StripTags;
use Zend\Filter\ToInt;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use Zend\Validator\StringLength;
class Album {
public $id;
public $artist;
public $title;
private $inputFilter;
public function exchangeArray(array $data) {
$this->id = !empty($data['_id']) ? $data['_id'] : null;
$this->artist = !empty($data['artist']) ? $data['artist'] : null;
$this->title = !empty($data['title']) ? $data['title'] : null;
}
public function setInputFilter(InputFilterInterface $inputFilter) {
throw new DomainException(sprintf(
'%s does not allow injection of an alternate input filter', __CLASS__
));
}
public function getInputFilter() {
if ($this->inputFilter) {
return $this->inputFilter;
}
$inputFilter = new InputFilter();
$inputFilter->add([
'name' => 'id',
'required' => true,
'filters' => [
['name' => StripTags::class],
['name' => StringTrim::class],
],
'validators' => [
[
'name' => StringLength::class,
'options' => [
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
],
],
],
]);
$inputFilter->add([
'name' => 'title',
'required' => true,
'filters' => [
['name' => StripTags::class],
['name' => StringTrim::class],
],
'validators' => [
[
'name' => StringLength::class,
'options' => [
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
],
],
],
]);
$inputFilter->add([
'name' => 'artist',
'required' => true,
'filters' => [
['name' => StripTags::class],
['name' => StringTrim::class],
],
'validators' => [
[
'name' => StringLength::class,
'options' => [
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
],
],
],
]);
$this->inputFilter = $inputFilter;
return $this->inputFilter;
}
public function getArrayCopy() {
return [
'id' => $this->id,
'artist' => $this->artist,
'title' => $this->title,
];
}
}
And a form named AlbumForm as follows:
namespace Album\Form;
use Zend\Form\Form;
class AlbumForm extends Form
{
public function __construct($name = null)
{
// We will ignore the name provided to the constructor
parent::__construct('album');
$this->add([
'name' => 'id',
'type' => 'hidden',
]);
$this->add([
'name' => 'title',
'type' => 'text',
'options' => [
'label' => 'Title',
],
]);
$this->add([
'name' => 'artist',
'type' => 'text',
'options' => [
'label' => 'Artist',
],
]);
$this->add([
'name' => 'submit',
'type' => 'submit',
'attributes' => [
'value' => 'Go',
'id' => 'submitbutton',
],
]);
}
}
And a controller named AlbumController in which I have addAction as follows:
public function addAction() {
$form = new AlbumForm();
$form->get('submit')->setValue('Add');
$request = $this->getRequest();
if (!$request->isPost()) {
return ['form' => $form];
}
$album = new Album();
$form->setInputFilter($album->getInputFilter());
$form->setData($request->getPost());
if (!$form->isValid()) {
return ['form' => $form];
}
$album->exchangeArray($form->getData());
$this->table->saveAlbum($album);
return $this->redirect()->toRoute('album');
}
The module.config.php file is as follows and I see no problem with routing:
return [
// The following section is new and should be added to your file:
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
];
but, I cannot add a new album to the db. Once, I press fill the form and hit 'Add' in the Add form, nothing is added and I remain in the same page. Does anyone know where I have messed up?
You have an error on the Model Album. It could have the following change:
$inputFilter->add([
'name' => 'id',
'required' => true,
'filters' => [
['name' => ToInt::class],
],
]);

Zend Framework 3 Redirect

Background: I am using REST methods only.
I've called a create() method, which returns the id of the record I have created, and I want to call a different controller's get() method with that id.
module.config.php :
namespace PrivateStatement;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Method;
return [
'router' => [
'routes' => [
'privateStatement' => [
'type' => Literal::class,
'options' => [
'route' => '/private-statements/private-statements',
'defaults' => [
'controller' => Controller\PrivateStatementController::class,
],
],
'child_routes' => [
'get' => [
'type' => Method::class,
'options' => [
'verb' => 'get',
'defaults' => [
'modules' => [
],
],
],
'may_terminate' => true,
],
'post' => [
'type' => Method::class,
'options' => [
'verb' => 'post',
'defaults' => [
'modules' => [
],
'params' => [
],
'requestVo' => '',
'controller' => Controller\PrivateStatementCreateController::class,
],
],
'may_terminate' => true,
],
],
],
],
],
'view_manager' => [
'strategies' => [
'ViewJsonStrategy',
],
],
];
In the PrivateStatementCreateController, I have the create() function:
public function create($data)
{
$requiredParams = [
PrivateStatementConstants::COLUMN_PROPERTY_ID,
PrivateStatementConstants::COLUMN_STOCK_UNIT_ID,
PrivateStatementConstants::API_FROM,
PrivateStatementConstants::API_TO,
];
$validRequest = ControllerUtil::verifyRequiredParams($requiredParams, $data);
if ($validRequest) {
$personId = $this->authResult->getIdentity();
$id = $this->model->createPrivateStatementService(
$data[PrivateStatementConstants::COLUMN_PROPERTY_ID],
$data[PrivateStatementConstants::COLUMN_STOCK_UNIT_ID],
$data[PrivateStatementConstants::API_FROM],
$data[PrivateStatementConstants::API_TO],
$personId
);
if ($id) {
return $this->redirect()->toRoute('privateStatement', array('action' => 'get', 'params' => array('private_statement_id' => $id)));
} else {
$this->getResponse()->setStatusCode(Response::STATUS_CODE_400);
}
} else {
$this->getResponse()->setStatusCode(Response::STATUS_CODE_400);
}
return new JsonModel([]);
}
The part I'm currently struggling with is return $this->redirect()->toRoute('privateStatement', array('action' => 'get', 'params' => array('private_statement_id' => $id)));
When I call this an exception gets thrown with the message Part route may not terminate - I honestly don't know how to continue from here - I only need to call the get() function in the PrivateStatementController and return the results.

How to perform Recursion to Nth level?

Here is my single database structure.
I have one array which I will export in one file by var_export.
This is a sample array,
return [
'menus' => [
'products' => [
'name' => 'Products',
'link' => 'cctv.html',
'show' => true,
],
'companies' => [
'name' => 'Companies',
'link' => 'companies.html',
'show' => true,
],
],
'products' => [
'section_enabled' => [
'featured_products', 'categories', 'news', 'latest_products', 'case_studies', 'expert_commentary',
'videos', 'companies', 'topics',
],
'pages' => [
'child_category_page' => [
'middle' => [
'left' => [
'class' => 'col-md-9',
'sections' => [
[
'folder' => '',
'element' => 'page_heading',
'variables' => ['page_heading', 'articles'],
],
],
],
],
],
'product_profile_page' => [
'middle' => [
'left' => [
'class' => 'col-md-9',
'sections' => [
[
'folder' => '',
'element' => 'page_heading',
'variables' => ['page_heading'],
],
[
'folder' => 'products',
'element' => 'specifications',
'variables' => ['specifications', 'filters'],
],
],
],
],
],
],
],
'news' => [
'news_types' => [
'expert_commentary' => 'Etary',
'applications' => 'Mon',
'security_beat' => 'SB',
'round_table' => 'RT',
'case_studies' => [
'type' => 'Marcation',
'label' => 'Casies',
],
],
'url_lookup_values' => [
'caudies' => [
'value' => 'Marklication',
'config' => 'castudies',
],
],
],
];
I got the recursion trick from here.
But it doesn't solve my problem.
Here is what I have tried,
function generate_site_config()
{
$data = DB::table("SITE_CONFIGS")->where("parent_id", 0)->get();
$desired_array = [];
get_tree_site_configs($data,$desired_array,0,0);
// file_put_contents(config_path() . DIRECTORY_SEPARATOR . "frontend_configs_demo.php", '<?php return ' . var_export($data, true) . ';');
echo "success";die;
}
function get_tree_site_configs($inputArray, &$outputArray, $parent = 0, $level = 0){
foreach($inputArray as $cc_id => $sub_arr){
if($sub_arr->parent_id == $parent){
$outputArray[] = $sub_arr;
if($sub_arr->variable_value == ''){
$inputArray = DB::table("SITE_CONFIGS")->where("parent_id", $sub_arr->id)->get();
get_tree_site_configs($inputArray, $outputArray, $sub_arr->id, $level + 1);
}else{
pr($sub_arr);
pr($outputArray);die;
}
}
}
}
NOTE: chain will go until variable_value == '', if variable_value found then it stops the tree at that end, then it will look for other parents which are dangling.

urlManager for module Yii2

I've got a basic Yii2 project, in which i created a separate module "rest". I have set up urlManager in config/web.php file. It works fine for common url, but it seems to me it is not working with url starting with my module name: rest/.. I have actionAuth() in AuthController in my rest module, and it is accessible with this url: test.ru/auth/auth. But i want it to be accessible with this url:test.ru/auth. I tried to write like this in web.php :
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest\auth',
'extraPatterns' => [
'POST /' => 'auth',
],
'pluralize' => false,
],
],
],
But it does not work(not found error in browser).
I also tried like this:
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest\auth',
'extraPatterns' => [
'POST rest/auth' => 'auth',
],
'pluralize' => false,
],
],
],
It seems to me that urlManager does not want to work for module. Next i tried to write the same code in my Module.php in rest/ directory. But it produced many errors. I think because of the same error things like that dont work too:`
'class' => 'yii\rest\UrlRule',
'controller' => 'rest\city',
'extraPatterns' => [
'DELETE {id}' => 'delete',
],
`
So my question is: how to set up urlManager for module in Yii2? I need to configure HTTP DELETE method, post methods work without any settings in urlManager.
The whole web.php file:
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'language' => 'ru',
'components' => [
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'xxxxxxx',
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
// 'loginUrl' => ['site/login'],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest\user',
'except' => ['delete', 'create', 'update', 'index'],
'extraPatterns' => [
'GET all' => 'all',
]
],
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest\auth',
'extraPatterns' => [
'POST reg' => 'reg',
'POST auth' => 'auth',
'POST rest/auth' => 'auth',
],
'pluralize' => false,
],
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest\city',
'extraPatterns' => [
'DELETE {id}' => 'delete',
],
],
],
],
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
// 'basePath' => '#app/messages', // if advanced application, set #frontend/messages
'sourceLanguage' => 'en',
'fileMap' => [
//'main' => 'main.php',
],
],
],
],
],
'modules' => [
'admin' => [
'class' => 'app\modules\admin\Module',
],
'manager' => [
'class' => 'app\modules\manager\Module',
],
'rest' => [
'class' => 'app\modules\rest\Module',
],
'rbac' => [
'class' => 'mdm\admin\Module',
'controllerMap' => [
'assignment' => [
'class' => 'mdm\admin\controllers\AssignmentController',
/* 'userClassName' => 'app\models\User', */
'idField' => 'id',
'usernameField' => 'username',
],
],
'layout' => 'left-menu',
'mainLayout' => '#app/views/layouts/admin.php',
]
],
'aliases' => [
//'#mdm/admin' => 'app/mdm/admin',
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
}
return $config;
My Module.php code(commented code shows my attempt to write urlManager):
<?php
namespace app\modules\rest;
/**
* rest module definition class
*/
class Module extends \yii\base\Module
{
/**
* #inheritdoc
*/
public $controllerNamespace = 'app\modules\rest\controllers';
/**
* #inheritdoc
*/
public function init()
{
parent::init();
// custom initialization code goes here
\Yii::$app->user->enableSession = false;
$config = [
'components' => [
'basePath' => dirname(__DIR__),
// 'user' => [
// 'identityClass' => 'app\models\User',
// 'class' => 'app\models\User',
// 'enableSession' => false
// ],
// 'urlManager' => [
// 'enablePrettyUrl' => true,
// 'enableStrictParsing' => true,
// 'showScriptName' => false,
// 'rules' => [
// [
// 'class' => 'yii\rest\UrlRule',
// 'controller' => 'rest\city',
// 'extraPatterns' => [
// 'DELETE {id}' => 'delete',
// ],
// ],
// ],
// ],
'response' => [
'format' => \yii\web\Response::FORMAT_JSON,
'charset' => 'UTF-8',
'class' => 'yii\web\Response',
'on beforeSend' => function ($event) {
$response = $event->sender;
if(( $response->statusCode >= 200) && ( $response->statusCode < 300)) {
if(isset($response->data['_appErr'])) {
unset($response->data['_appErr']);
$response->data = [
'success' => false,
'error' => $response->data,
'data' => null,
];
} else {
$response->data = [
'success' => $response->isSuccessful,
'error' => null,
'data' => $response->data,
];
}
} else {
if($response->statusCode == 401) {
$response->data = [
'success' => false,
'error' => [
'code' => 9,
'message' => 'Unauthorized',
'user_msg' => 'You need to be authorized',
],
'data' => null,
];
}
// else {
// $response->data = [
// 'success' => false,
// 'error' => [
// 'code' => 1,
// 'message' => 'server has returned '.$response->statusCode.' error',
// ],
// 'data' => null,
// ];
// }
}
},
],
],
];
\Yii::configure(\Yii::$app, $config);
}
}
Try this:
namespace yii\rest;
class UrlRule extends Object implements UrlRuleInterface {
public function parseRequest($manager, $request) {
list($e1, $e2) = sscanf($request->getPathInfo(), '%[a-zA-Z]/%[a-zA-Z]');
if ($e1 === 'auth' && $e2 === '') {
return ['/auth/auth', $request->queryParams];
}
return false;
}
}
Use forward slash(/) while defining the controller value in the rules array.
This will work:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest/user',
'except' => ['delete', 'create', 'update', 'index'],
'extraPatterns' => [
'GET all' => 'all',
]
],
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest/auth',
'extraPatterns' => [
'POST reg' => 'reg',
'POST auth' => 'auth',
],
'pluralize' => false,
],
[
'class' => 'yii\rest\UrlRule',
'controller' => 'rest/city',
'extraPatterns' => [
'DELETE {id}' => 'delete',
],
],
]
Check out the documentation here: http://www.yiiframework.com/doc-2.0/guide-rest-versioning.html

Categories