maltyxx/bower
Composer 安装命令:
composer require maltyxx/bower
包简介
Bower for CodeIgniter 3
README 文档
README
Bower for Codeigniter 3
Requirements
- PHP 5.3.x (Composer requirement)
- CodeIgniter 3.0.x
Installation
Step 1 Installation by Composer
Run composer
composer require maltyxx/bower
Step 2 Configuration
Edit file ./application/config/config.php set $config['composer_autoload'] = FALSE; to $config['composer_autoload'] = FCPATH.'vendor/autoload.php';
Duplicate configuration file ./application/third_party/bower/config/bower.php in ./application/config/development/bower.php.
Step 3 Examples
Bower file is located in ./application/config/development/bower.php.
$config['css']['default'] = array( array('src' => base_url('bower_components/font-awesome/css/font-awesome.css')), array('src' => base_url('assets/css/custom.css')) ); $config['js']['default'] = array( array('src' => base_url('bower_components/jquery/dist/jquery.js')), array('src' => base_url('assets/js/custom.js')) );
Controller file is located in /application/controllers/Exemple.php.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Exemple extends CI_Controller { public function exemple1() { $this->load->add_package_path(APPPATH.'third_party/bower'); $this->load->library('bower'); $this->load->remove_package_path(APPPATH.'third_party/bower'); $this->load->view('exemple_index', array( 'css' => $this->bower->css('default'), 'js' => $this->bower->js('default') )); } public function exemple2() { $this->load->add_package_path(APPPATH.'third_party/bower'); $this->load->library('bower'); $this->load->remove_package_path(APPPATH.'third_party/bower'); $js = $this->bower->js('default'); $js[] = $this->bower->add('https://maps.googleapis.com/maps/api/js'); $this->load->view('exemple_index', array( 'js' => $js )); } public function exemple3() { $this->load->add_package_path(APPPATH.'third_party/bower'); $this->load->library('bower'); $this->load->remove_package_path(APPPATH.'third_party/bower'); $css = $this->bower->css('default'); $css[] = $this->bower->add(base_url('assets/css/custom2.css'), array('embed' => TRUE)); $this->load->view('exemple_index', array( 'css' => $css, 'js' => $this->bower->js('default') )); } }
View file is located in /application/views/exemple_index.php.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Welcome to CodeIgniter</title> <?php foreach ($css as $file) { ?> <link href="<?php echo $file['src']; ?>" media="all" rel="stylesheet" /> <?php } ?> </head> <body> <?php foreach ($js as $file) { ?> <script src="<?php echo $file['src']; ?>"></script> <?php } ?> </body> </html>
Step 4 Compilation with Grunt
This plugin requires Grunt >=0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-contrib-cssmin --save
npm install grunt-contrib-uglify --save
Grunt file is located in /Gruntfile.js.
module.exports = function(grunt) { grunt.initConfig({ cssmin: { options: { rebase: true, report: "min", sourceMap: false }, target: { files: { "build/default.min.css": [ 'bower_components/font-awesome/css/font-awesome.css', 'assets/css/custom.css' ] } } }, uglify: { target: { files: { "build/default.min.js": [ 'bower_components/jquery/dist/jquery.js', 'assets/js/custom.js' ] } } } }); grunt.loadNpmTasks("grunt-contrib-cssmin"); grunt.loadNpmTasks("grunt-contrib-uglify"); grunt.registerTask("build", ["cssmin", "uglify"]); };
Step 5 For example the production environment
Bower file is located in ./application/config/production/bower.php.
$config['css']['default'] = array( array('src' => base_url('build/default.min.css')) ); $config['js']['default'] = array( array('src' => base_url('build/default.min.js')) );
maltyxx/bower 适用场景与选型建议
maltyxx/bower 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.2k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 08 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 maltyxx/bower 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 maltyxx/bower 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: 未知许可证
- 更新时间: 2015-08-03