├── .gitignore ├── application ├── config │ ├── vendorlibs_site.example.php │ └── vendorlibs.php └── hooks │ └── vendorlibs.php ├── README ├── dd-p2.xml ├── INSTALL └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /application/config/vendorlibs_site.example.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | vendorlibs - Dragonfly Development's Vendor Libs CodeIgniter Add-On 2 | http://code.google.com/p/dd-ci-vendorlibs/ 3 | 4 | 5 | vendorlibs for CodeIgniter is intended to allow for easily adding third party 6 | (vendor) libraries to the include path. 7 | 8 | The implementation involves a pre-system hook and a standardized placement 9 | of vendor libraries. 10 | 11 | APPPATH . 'vendors' 12 | BASEDIR . 'vendors' 13 | 14 | Every directory inside of either of these two directories will be added 15 | to the PHP include path. For example: 16 | 17 | system/application/vendors/fancy-orm/Orm.php 18 | 19 | In this case, 'system/application/vendors/fancy-orm' will be added to the 20 | include path and one will be able to require 'Orm.php' with either of the 21 | following: 22 | 23 | require 'Orm.php'; 24 | require 'fancy-orm/Orm.php'; 25 | 26 | 27 | Inspired by CakePHP's Vendor concept. 28 | http://book.cakephp.org/view/538/Loading-Vendor-Files 29 | -------------------------------------------------------------------------------- /dd-p2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.1.1 4 | vendorlibs - Dragonfly Development CodeIgniter Vendor Libs Add-on 5 | http://code.google.com/p/dd-ci-vendorlibs/ 6 | Copyright (c) 2010 Dragonfly Development 7 | Licensed under the New BSD License. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | vendorlibs - Dragonfly Development's Vendor Libs CodeIgniter Add-On 2 | http://code.google.com/p/dd-ci-vendorlibs/ 3 | 4 | 5 | Copy the dd-ci-vendorlibs distribution files: 6 | 7 | cp dd-ci-vendorlibs/application/hooks/vendorlibs.php \ 8 | system/application/hooks/ 9 | 10 | cp dd-ci-vendorlibs/application/config/vendorlibs.php \ 11 | system/application/config/ 12 | 13 | cp dd-ci-vendorlibs/application/config/vendorlibs_site.example.php \ 14 | system/application/config/ 15 | 16 | Modify path/to/system/application/config/hooks.php and add the following: 17 | 18 | $hook['pre_system'][] = array( 19 | 'class' => 'dd_ci_VendorLibs', 20 | 'function' => 'preSystem', 21 | 'filename' => 'vendorlibs.php', 22 | 'filepath' => 'hooks' 23 | ); 24 | 25 | 26 | Create a system and/or application vendors folders. 27 | 28 | For libraries used by potentially more than one CodeIgniter application, create 29 | a vendors/lib folder under BASEDIR: 30 | 31 | mkdir -p path/to/your/system/vendors/lib 32 | 33 | 34 | For libraries used by a specific application, create a vendors/lib folder under 35 | APPPATH: 36 | 37 | mkdir -p path/to/your/system/application/vendors/lib 38 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Dragonfly Development Inc 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Dragonfly Development Inc nor the names of its 13 | contributors may be used to endorse or promote products derived from 14 | this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /application/hooks/vendorlibs.php: -------------------------------------------------------------------------------- 1 | load('vendorlibs', null, true); 48 | 49 | $allPaths = array(); 50 | 51 | $allPaths[] = $CFG->item('vendorlibs_site_paths'); 52 | $allPaths[] = $CFG->item('vendorlibs_paths'); 53 | 54 | $allPaths[] = array_values($CFG->item('vendorlibs_map')); 55 | 56 | if ( $CFG->item('vendorlibs_scan') ) { 57 | $allPaths[] = $this->readDirs(APPPATH); 58 | $allPaths[] = $this->readDirs(BASEPATH); 59 | } else { 60 | $staticVendors = array(); 61 | foreach ( $CFG->item('vendorlibs_vendors') as $vendor ) { 62 | $vendorApp = APPPATH . 'vendors/' . $vendor; 63 | $vendorBase = BASEPATH . 'vendors/' . $vendor; 64 | if ( file_exists($vendorApp) ) $staticVendors[] = $vendorApp; 65 | if ( file_exists($vendorBase) ) $staticVendors[] = $vendorBase; 66 | } 67 | $allPaths[] = $staticVendors; 68 | } 69 | 70 | $allPaths[] = explode(PATH_SEPARATOR, get_include_path()); 71 | $allPathsFinal = array('.'); 72 | foreach ( $allPaths as $allPathsPart ) { 73 | foreach ( $allPathsPart as $path ) { 74 | if ( $path != '.' ) $allPathsFinal[] = $path; 75 | } 76 | } 77 | 78 | set_include_path(implode(PATH_SEPARATOR, $allPathsFinal)); 79 | 80 | } 81 | 82 | } 83 | ?> 84 | -------------------------------------------------------------------------------- /application/config/vendorlibs.php: -------------------------------------------------------------------------------- 1 | 103 | --------------------------------------------------------------------------------