Yii

Yii2在CentOS下的安装与使用

自闭症网瘾萝莉.ら 提交于 2020-02-25 01:12:30
1、安装composer root用户执行: php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" php composer-setup.php mv composer.phar /usr/local/bin/composer mkdir /data/site/localhost/yii/ chown -R Tristone.Tristone /data/site/localhost/yii/ 2、更换composer镜像源为阿里云 Composer不能使用root用户操作,只能使用普通用户(Tristone)来操作。 cd /data/site/localhost/yii/ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ composer clear-cache 3、安装Yii 在普通用户下输入以下命令安装 $ cd /data/site/localhost/yii/ $ composer create-project yiisoft/yii2-app-basic basic 这样就完成了Yii的安装。 4、安装 Assets Yii依靠 Bower 和/或

IAM Role Name considred as Class in Yii 1

家住魔仙堡 提交于 2020-02-23 10:14:20
问题 I have attached the policy to EC2 IAM role to access AWS services. After that i have have used below code in Yii 1 controller file: ExampleController.php class ExampleController extends Controller { public function init() { require_once dirname(dirname(__FILE__)) . '/extensions/awsv3/vendor/autoload.php'; $config = array( 'version' => 'latest', 'region' => 'us-west-2', ); $s3_instance = new \Aws\Ssm\SsmClient($config); $result = $s3_instance->getParameters([ 'Names' => array('host_name'),

IAM Role Name considred as Class in Yii 1

試著忘記壹切 提交于 2020-02-23 10:13:39
问题 I have attached the policy to EC2 IAM role to access AWS services. After that i have have used below code in Yii 1 controller file: ExampleController.php class ExampleController extends Controller { public function init() { require_once dirname(dirname(__FILE__)) . '/extensions/awsv3/vendor/autoload.php'; $config = array( 'version' => 'latest', 'region' => 'us-west-2', ); $s3_instance = new \Aws\Ssm\SsmClient($config); $result = $s3_instance->getParameters([ 'Names' => array('host_name'),

IAM Role Name considred as Class in Yii 1

我的未来我决定 提交于 2020-02-23 10:13:02
问题 I have attached the policy to EC2 IAM role to access AWS services. After that i have have used below code in Yii 1 controller file: ExampleController.php class ExampleController extends Controller { public function init() { require_once dirname(dirname(__FILE__)) . '/extensions/awsv3/vendor/autoload.php'; $config = array( 'version' => 'latest', 'region' => 'us-west-2', ); $s3_instance = new \Aws\Ssm\SsmClient($config); $result = $s3_instance->getParameters([ 'Names' => array('host_name'),

yii2框架随笔8

左心房为你撑大大i 提交于 2020-02-22 05:21:49
今天我们继续来探索Component.php /** * Makes sure that the behaviors declared in [[behaviors()]] are attached to this component.   *确保在声明的行为[behaviors()]]安装此组件。 */ public function ensureBehaviors() { // 如果$this->_behaviors为空,获取$this->behaviors()中的behaviors,并存储到$this->_behaviors数组中 if ($this->_behaviors === null) { $this->_behaviors = []; foreach ($this->behaviors() as $name => $behavior) { $this->attachBehaviorInternal($name, $behavior); } } } /** * Attaches a behavior to this component. * * 内部使用的为该对象添加behavior的方法 * * @param string|integer $name the name of the behavior. If this is an integer, it means

php常见的三种框架比较

荒凉一梦 提交于 2020-02-19 11:38:35
前言 最近在网上查了一下php的最常用的三种框架tp,laravel,yii2的资料并结合自己的理解总结一下三种框架的优缺点,话不多说请看正文。 正文 yii2: 优点:gii蛮不错的,简化了开发流程,可以生成绝大数的代码,开发后台等效率还是蛮高的 缺点:前后端完全的分离的趋势下,yii2前后端的耦合的还是有些重了 laravel: 优点:优雅,框架结构组织清晰(抽象了中间件,任务,服务等模块),提供的artisan开发工具开发效率高,社区活跃完善,并且提供了简化的轻量级框架lumen 缺点:貌似代码有些过于优雅丧失了一些性能 lumen 优点:基本结构同Laravel,但是已经为API开发做了一些优化,非常适合RESTful的API服务器 缺点 缺点:如果要用Lumen做传统web,需要自行加载一些Service,比如session;此外,有些为Laravel写的包会不太兼容Lumen,需要自行修改和调整 thinkphp3.2 优点:简单明了方便快捷,上手快 缺点:缺少面向对象的设计,框架社区相关的辅助工具少 thinkphp5 优点:基本面向对象,可能借鉴了laravel或者ruby on rails, 对于开发者更加友善了 缺点:框架社区相关的辅助工具仍然少 为什么不选TP5.x TP5.x明显借鉴了很多Laravel的设计,但是感觉学得不伦不类的,就行中国特色的xxx一样

Yii笔记之filter用法

大城市里の小女人 提交于 2020-02-18 10:36:42
Filter 是一个代码片段,被配置用来在一个控制器的动作执行之前/后执行. 例如, an access control filter 可被执行以确保在执行请求的 action 之前已经过验证; 一个 performance filter 可被用来衡量此 action 执行花费的时间. 一个 action 可有多个 filter. filter 以出现在 filter 列表中的顺序来执行.一个 filter 可以阻止当前 action 及剩余未执行的 filter 的执行. 一个 filter 可被定义为一个 controller 类的方法. 此方法的名字必须以 filter 开始. 例如,方法 filterAccessControl 的存在定义了一个名为 accessControl 的 filter. 此filter 方法必须如下:public function filterAccessControl($filterChain) { // call $filterChain->run() to continue filtering and action execution } 复制代码 $filterChain 是 CFilterChain 的一个实例, CFilterChain 代表了与被请求的 action 相关的 filter 列表. 在此 filter 方法内部,

yii 载入css or js

元气小坏坏 提交于 2020-02-11 19:51:52
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/TableView.js"); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/datechooser.js"); Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . "/css/datechooser.css"); 参考资料 Yii::app()->clientScript->registerScript('user_is_guest', '$(document).ready(function(){$(".login-box-bg").show();$("#login-user-box").show();})', CClientScript::POS_READY); Yii::app()->clientScript->registerScript('user_is_guest', "alert('".Yii::app()->user->getFlash('user_is_guest')."');", CClientScript::POS_READY); 参考资料 来源:

Yii 框架学习--02 进阶

痴心易碎 提交于 2020-02-11 05:10:48
本文以YII 2.0.7为例。 应用结构 入口文件 文件位置: web/index.php <?php //开启debug,应用会保留更多日志信息,如果抛出异常,会显示详细的错误调用堆栈 defined('YII_DEBUG') or define('YII_DEBUG', true); //环境定义 defined('YII_ENV') or define('YII_ENV', 'dev'); //dev,prod // 注册 Composer 自动加载器 require(__DIR__ . '/../vendor/autoload.php'); // 包含 Yii 类文件 require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); // 加载应用配置 $config = require(__DIR__ . '/../config/web.php'); // 创建、配置、运行一个应用 (new yii\web\Application($config))->run(); 需要注意的是,如果想通过命令行方式(cli)访问应用,入口文件是根目录下的 yii 。里面的内容实质是php代码,与 config/web.php 类似。Windows下请使用 yii.bat 。该文件在Linux下需要有执行权限,这样用户就能通过命令 ./yii

yii源码学习心得

核能气质少年 提交于 2020-02-11 03:46:16
1.通过看源代码,对yii的框架学习有了更多的认识和理解 assets 前端资源文件夹,用于管理css js等前端资源文件等 commands 包含命令行命令,文件为控制器文件 config 应用的配置文件 controllers 控制器文件 mail (应用的前后台和命令行的与邮件相关的布局文件等) modles 模型文件 runtime 程序运行时生成的临时文件 tests 用于各种测试程序的测试类文件 vendor 就是各种第三方的程序。 这是Composer安装的其他程序的存放目录,包含Yii框架本身。 如果你向 composer.json 目录增加了新的安装的程序,下次调用Composer的时候, 就会把新安装的目录也安装在这个 vendor 下面。 views 视图文件 web 入口文件的存放目录,对于Web服务器可以访问的目录。其他所有的目录不对Web用户显示。 requirements.php 测试环境是否符合yii框架的要求 yii 文件 它没有扩展名,我们不好知道其具体类型。 但是从文件内容的第一行 #!/usr/bin/env php 来看,这是一个bash脚本。 第一行在告诉bash,也在告诉我们,这是一个使用PHP运行的脚本。 对于Windows系统而言,命令行的入口脚本仍然是 yii ,但是命令行下无法直接运行。所以Yii为我们准备了一个 yii.bat