Helpers\URL】的更多相关文章

Helpers\URL The URL class is used for having handy methods or redirecting the page and returning the path to the current template. Redirect - To redirect to another page instead of using a header call the static method redirect: Url::redirect('path/t…
参考文章: http://blog.csdn.net/iefreer/article/details/21325371 以http://localhost/basic/web/index.php?r=article/index为例 echo \yii\helpers\Url::base(); //输出/basic/web echo \yii\helpers\Url::base(true) //输出http://localhost/basic/web //home是输出首页,加上true是输出加域…
路由和URL生成 当一个YII应用开始处理一个请求的时候,它首先要做的便是将请求的URL转化成一个路由.路由的作用是用于后续实例化相应的控制器和操作,以便处理请求,整个处理过程便叫做路由.路由的逆过程叫做URL生成,是指用给定的路由和参数信息来生成一个URL.当使用生成的URL来发出请求的时候,路由处理的过程又能够再次将其解析还原出原始的路由和参数信息. 主要负责路由和URL生成工作的是URL管理器,其被注册成为应用组件.URL管理器提供方法parseRequest()来解析请求,解析出其中的路…
Url 帮助类 获得通用 URL 记住 URLs 检查相对 URLs Url 帮助类提供一系列的静态方法来帮助管理 URL. 获得通用 URL 有两种获取通用 URLS 的方法 :当前请求的 home URL 和 base URL . 为了获取 home URL ,使用如下代码: $relativeHomeUrl = Url::home(); $absoluteHomeUrl = Url::home(true); $httpsAbsoluteHomeUrl = Url::home('https'…
一.Yii Url美化,配置urlManager组件 'urlManager' => [ 'enablePrettyUrl' => true, // 开启URL美化,可以去掉 index.php?r= 'showScriptName' => false, // 如果设置为 true,会显示 index.php 'suffix' => '.html', // 实现伪静态 'rules' => [ // 在 rules 中设置自定义规则 '<controller:\w+&g…
Yii 各种url地址写法 echo Url::home(); 生成入口地址/yii2test/frontend/web/index.php: echo  Url::base();生成入口文件夹地址:/yii2test/frontend/web echo  Url::base(true); 生成带有域名的入口文件夹地址:http://localhost/yii2test/frontend/web echo Url::to(); 生成当前浏览器文档地址(同时携带参数)/yii2test/front…
echo Url::home(); 生成入口地址/yii2test/frontend/web/index.php: echo  Url::base();生成入口文件夹地址:/yii2test/frontend/web echo  Url::base(true); 生成带有域名的入口文件夹地址:http://localhost/yii2test/frontend/web echo Url::to(); 生成当前浏览器文档地址(同时携带参数)/yii2test/frontend/web/index.…
在yii框架里有前台和后台页面,举例前台url重写. 控制器与路由 控制器以Controller作为后缀,继承自yii\web\Controller; 动作以action作为前缀,public访问修饰; 控制器ID 类名去后缀,全部转为小写,如果是驼峰命名多个单词转为中杠分割; 动作ID 去前缀,全部转为小写,如果是驼峰命名多个单词,转为中杠分割: 路由如何指向动作:控制器ID/动作ID URL访问规则:index.PHP?r=路由 传参使用&参数=值 的方式 默认路由site定义在yii\we…
0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三)--实现基础功能:处理get请求url参数 4.使用Typescript重构axios(四)--实现基础功能:处理post请求参数 5.使用Typescript重构axios(五)--实现基础功能:处理请求的header 6.使用Typescript重构axios(六)--实现基础功能:获取响应数据…
要想使用Yii分页类第一步:在控制器层加载分页类 use yii\data\Pagination;第二步: 使用model层查询数据,并用分分页,限制每页的显示条数$data = User::find();  //User为model层,在控制器刚开始use了field这个model,这儿可以直接写Field,开头大小写都可以,为了规范,我写的是大写$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' =>…
1.获取源码:https://github.com/chenkby/yii2-region 2.安装 添加到你的composer.json文件 "chenkby/yii2-region": "dev-master" 切换到项目目录 composer update; 3.配置 1) 在地区的Model中添加以下方法 public static function getRegion($parentId=0) { $result = static::find()->…
classes.php在yii运行的时候将被自动加载,位于yii2文件夹底下. <?php /** * Yii core class map. * * This file is automatically generated by the "build classmap" command under the "build" folder. * Do not modify it directly. * * @link http://www.yiiframewor…
sqlmap 较专业的sql注入工具YII2  activeform   注意传过来的modle的rules规则 <?php$form=\yii\widgets\ActiveForm::begin(['action'=>\yii\helpers\Url::to(['news/testadd'])]);echo $form->field($model, 'title')->textInput(['class'=>'test1']);echo $form->field($m…
今天配置了一下yii2 的路由,用 /index.php?r=... 这样的路由,实在是不太习惯,所以我便试着把yii2 的路由,写成laravel 那般,以下为详情 1.环境介绍 lnmp php5.6, mysql5.5, lnmp1.2 yii2-advanced 2.在 frontend/config/main.php 中,添加以下内容 'urlManager' => [ 'enablePrettyUrl' => true, //开启URL美化  'showScriptName' =&…
Yii 是一个高性能的,适用于开发 WEB2.0 应用的 PHP 框架. Yii目前有两个主要的版本: 2.0 和 1.1.本文以YII 2.0.7为例. 环境需求 Yii2.0 框架有一些系统上的需求: PHP 版本 >= 5.4 Mcrypt PHP 扩展 OpenSSL PHP 扩展 Mbstring PHP 扩展 特点 安装 Yii可以通过Composer或者压缩包安装. 使用Composer安装 与安装Laravel框架类似,很多人会卡在这一步.要么是不会Composer,要么就是无法…
h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child { margin-top: 0; padding-top: 0; } a:first-child h1, a:first-child h2, a:first-child h3, a:fi…
componets配置: 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://test:123456@127.0.0.1:27017/yiimongodb', ],   控制器: <?php namespace frontend\controllers; use Yii; use yii\helpers\Url; use yii\mongodb\Query; use yii\web\Con…
Yii/web中的Controller类,实现参数绑定,启动csrf验证功能,重定向页面功能: namespace yii\web; use Yii; use yii\base\InlineAction; use yii\helpers\Url; /** * Controller is the base class of web controllers. * * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class Cont…
1.文章表关联 <?php //...other code //关联 public function getCate(){ return $this->hasOne(ArticleCate::className(),['id' => 'cid']); } ?> 2.搜索模型common/models/search/创建ArticleSearch.php <?php namespace common\models\search; use Yii; use yii\base\Mo…
<?php$form=\yii\widgets\ActiveForm::begin(['action'=>\yii\helpers\Url::to('name/create')]);echo $form->field($model,'name')->textInput( );echo $form->field($model,'img')->fileInput();echo \yii\helpers\Html::submitButton();$form->end()…
导航栏 <?php use yii\helpers\Url; /** * $navbar说明 * label:显示的标签 * url:跳转地址 * action:判断激活的操作 * class:原始样式 * disabled:反选时被禁用 */ $navbar = [ [ 'label' => '学校管理', 'url' => Url::toRoute(['/setting-manage/school']), 'action' => ['setting-manage/school'…
1.model中models/article.php 1 <?php 2 3 namespace app\models; 4 5 use Yii; 6 7 /** 8 * This is the model class for table "yii2_article". 9 * 10 * @property string $id 11 * @property integer $category_id 12 * @property string $title 13 * @prope…
想要了解更多YII,PHP方面内容,请关注本博客. 基础总结 1.修改默认控制器/方法 yii默认是site控制器,可以在web.php中设置$config中的'defaultRoute'='xxxx';使用自定义默认的控制器.也可以改写Yii::$app->defaultRoute属性. yii的默认方法是index,可以在vender/yiisoft/yii2/base/Controller.php 中进行初始设置,也可以在控制器中改写defaltAction='action'. 2.添加独…
添加 use yii\helpers\Url; view中的连接 <?= Url::toRoute('post/index');?>//post为你的当前控制器名,index为view模版…
要想使用Yii分页类 第一步:在控制器层加载分页类 use yii\data\Pagination; 第二步: 使用model层查询数据,并用分分页,限制每页的显示条数 $data = Zhao::find();  //zhao为model层,在控制器刚开始use了field这个model,这儿可以直接写Field,开头大小写都可以,为了规范,我写的是大写 $pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' =&…
结合yii上传做的图片上传后立即显示,自己琢磨的,有点low <script type="text/javascript">//下面用于图片上传预览功能function setImagePreview(avalue) {var docObj=document.getElementById("doc"); var imgObjPreview=document.getElementById("preview");if(docObj.fil…
直接贴代码了 ---------------------------------------------------------------------------------------------------------- 先新建一个model文件 UploadForm.php 内容: <?phpnamespace app\models; use yii\base\Model;use yii\web\UploadedFile; /*** UploadForm is the model beh…
--------------------------------------------------------------------------------------------------- 首先你得调整模型类,在 file 验证规则里增加一个 maxFiles 选项,用以限制一次上传文件的最大数量. upload()方法也得修改, 以便一个一个地保存上传的文件. --------------------------------------------------------------…
先创建一个(UploadForm.php)模型层 <?phpnamespace app\models; use yii\base\Model;use yii\web\UploadedFile; /*** UploadForm is the model behind the upload form.*/class UploadForm extends Model{    /**    * @var UploadedFile file attribute    */    public $file;…
<script type="text/javascript"> $(document).ready(function(){ var callbacks_list = $('.demo-callbacks'); $('.demo-list input').on('ifCreated ifClicked ifChanged ifChecked ifUnchecked ifDisabled ifEnabled ifDestroyed', function(event){ }).i…