rayamedia / yima-static-uri-helper
此包的最新版本(dev-master)没有可用的许可证信息。
查看助手以定义可配置和按需静态uri,用于加载文件资源或生成动态链接。
dev-master
2015-06-21 10:44 UTC
Requires
- php: >=5.3.3
- rayamedia/yima-plugin-installer: dev-master
This package is auto-updated.
Last update: 2024-09-24 04:54:45 UTC
README
此模块是Yima应用框架的一部分
为什么需要这个模块?
可配置静态资源
需要某些资源的模块可以使用资源键和源URL。
/* * Set from merged config */ return array( 'statics.uri' => array( 'Twitter.Bootstrap' => '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.0/js/bootstrap.min.js', ), // ... );
/* * Set from any where that we can get helper object */ $staticsUri = $this->staticsUri('self'); // from within view you can get self object like this $staticsUri->setPath('Key.Of.Uri', 'uri/path/to/target');
存储键路径
echo $this->staticsUri('Twitter.Bootstrap'); // output: //cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.1.0/js/bootstrap.min.js
默认存储键路径
echo $this->staticsUri('basepath'); // output in exp.: /app_dir echo $this->staticsUri('serverurl'); // output in exp.: http://raya-media.com/
生成动态URI
$this->staticsUri('self') ->setPath('ondemand.rayamedia.server', '$protocol://raya-media.com'); echo $this->staticsUri('ondemand/rayamedia/server', array('protocol' => 'http')); // output: http://raya-media.com
使用默认值生成动态URI
$basepath
和 $serverurl
是默认值。
$siteUser = 'payam'; $this->staticsUri('self') ->setVariable('user', $siteUser); // register default variable // this uri not registered path // we also can use this for registered path echo $this->staticsUri( '$basepath/www/$user/some/$folder', array('folder' => 'media') ); // output: /app_dir/www/payam/some/media echo $this->staticsUri( '$basepath/www/$user/some/$folder', array('basepath' => '/alterpath', 'folder' => 'media') ); // output: /alterpath/www/payam/some/media /* Pass variables by order * in this format helper don't support default variables */ echo $this->staticsUri( '$var1/www/$var2/some/$var3', '/alterpath', $user, $media ); // output: /alterpath/www/payam/some/media
安装
Composer安装
在您的 composer.json
中添加 require
rayamedia/yima-static-uri-helper
或克隆到模块文件夹
在应用配置中启用模块
支持
要报告错误或请求功能,请访问问题跟踪器。
请随时通过新问题、请求和代码修复或新功能来贡献。