/application
/modules
/auth
/cache
/database
/orm
/system
index.php
.htaccess
<?php defined('SYSPATH') or die('No direct script access.'); class Kohana extends Kohana_Core { /** * Changes the currently enabled modules. Module paths may be relative * or absolute, but must point to a directory: * * Kohana::modules(array('modules/foo', MODPATH.'bar')); * * @param array list of module paths * @return array enabled modules */ public static function modules(array $modules = NULL) { if ($modules === NULL) { // Not changing modules, just return the current set return Kohana::$_modules; } // Start a new list of include paths, APPPATH first $paths = array(APPPATH); foreach ($modules as $name => $path) { if (is_file($path.'.phar')) { // Add phar-version of the the module to include paths $paths[] = $modules[$name] = 'phar://'.realpath($path.'.phar').DIRECTORY_SEPARATOR; } elseif(is_dir($path)) { // Add the module to include paths $paths[] = $modules[$name] = realpath($path).DIRECTORY_SEPARATOR; } else { // This module is invalid, remove it unset($modules[$name]); } } // Finish the include paths by adding SYSPATH $paths[] = SYSPATH; // Set the new include paths Kohana::$_paths = $paths; // Set the current module list Kohana::$_modules = $modules; foreach (Kohana::$_modules as $path) { $init = $path.'init'.EXT; if (is_file($init)) { // Include the module initialization file once require_once $init; } } return Kohana::$_modules; } } // End Kohana
/** * The directory in which the Kohana resources are located. The system * directory must contain the classes/kohana.php file. * * @see http://kohanaframework.org/guide/about.install#system */ $system = 'system.phar';
define('SYSPATH', 'phar://'.realpath($system).DIRECTORY_SEPARATOR);
<?php require_once 'phing/Task.php'; class Rename extends Task { /** * Directory with the files to rename * * @var string */ protected $targetDir; /** * Extension of files to rename * * @var string */ protected $ext = 'rename'; /** * Files array * * @var array */ protected $filesets = array(); /** * Task initialization * * @return boolean */ public function init() { return true; } /** * Sets target directory with the files to rename * * @param string $targetDir Target directory * @return void */ public function setTargetDir($targetDir) { $this->targetDir = $targetDir; } /** * Sets extension of files to rename * * @param string $ext Extension of files to rename * @return void */ public function setExt($ext) { $this->ext = $ext; } /** * Creates fileSet parameter * * @return array Fileset array */ public function createFileSet() { $num = array_push($this->filesets, new FileSet()); return $this->filesets[$num - 1]; } /** * Entry point - file renaming * * @throws BuildException * @return void */ public function main() { // We may have several filesets - // will process them all foreach ($this->filesets as $fs) { try { // Get an files array for current fileset $files = $fs->getDirectoryScanner($this->project) ->getIncludedFiles(); $fullPath = realpath($fs->getDir($this->project)); foreach ($files as $file) { //if (is_file($fullPath.$file)) //{ // Get file extension $ext = pathinfo($fullPath.'/'.$file, PATHINFO_EXTENSION); $this->log('Ext '.$ext); if ($ext == $this->ext) { $new = $fullPath.'/'.str_replace('.'.$this->ext, '', $file); $this->log('Renaming file '.$fullPath.'/'.$file.' to '.$new); // If file already exists, remove it if (is_file($new)) unlink($new); // Then rename our file rename($fullPath.'/'.$file, $new); } //} } } catch (BuildException $be) { if ($this->failonerror) { throw $be; } else { $this->log($be->getMessage(), Project::MSG_WARN); } } } } }
<?xml version="1.0"?> <project name="make_project" basedir=".." default="build"> <!-- --> <property name="source_dir" value="/path/to/source/directory/" override="false" /> <property name="deploy_dir" value="/path/to/deploy/directory/" override="false" /> <!-- , --> <target name="copy"> <copy todir="${deploy_dir}"> <fileset dir="${source_dir}" defaultexcludes="true"> <include name="**" /> <exclude name=".git/" /> <exclude name="**/.git/" /> <exclude name="*.gitignore" /> <exclude name="**/*.gitignore" /> <exclude name="*.gitmodules" /> <exclude name="**/*.gitmodules" /> <exclude name="*.sql" /> <exclude name="**/*.sql" /> <exclude name="build.xml" /> <exclude name="*.md" /> <exclude name="*.txt" /> <exclude name="**/*.txt" /> <exclude name="application/cache/**" /> <exclude name="application/logs/**" /> <exclude name="modules/userguide/" /> <exclude name="modules/**/config/" /> <exclude name="system/guide/" /> <exclude name="system/tests/" /> <exclude name="modules/**/guide/" /> <exclude name="modules/**/tests/" /> </fileset> </copy> </target> <!-- *.rename --> <target name="rename_prepared_files" depends="copy"> <taskdef name="rename" classname="phing.tasks.my.Rename" /> <echo>Renaming prepared files</echo> <rename ext="rename"> <fileset dir="${deploy_dir}"> <include name="**/*.rename" /> </fileset> </rename> </target> <!-- --> <target name="make_empty_dirs" depends="rename_prepared_files"> <mkdir dir="${deploy_dir}/application/logs" /> <mkdir dir="${deploy_dir}/application/cache" /> </target> <!-- --> <target name="pack_to_phar" depends="make_empty_dirs"> <pharpackage destfile="${deploy_dir}/system.phar" basedir="${deploy_dir}/system/" signature="md5"> <fileset dir="${deploy_dir}/system/"> <include name="**" /> </fileset> <metadata> <element name="version" value="3.1.3.1" /> <element name="authors"> <element name="Kohana Team" /> </element> </metadata> </pharpackage> <!-- ... --> <pharpackage destfile="${deploy_dir}/modules/orm.phar" basedir="${deploy_dir}/modules/orm/" signature="md5"> <fileset dir="${deploy_dir}/modules/orm/"> <include name="**" /> </fileset> <metadata> <element name="version" value="3.1.3.1" /> <element name="authors"> <element name="Kohana Team" /> </element> </metadata> </pharpackage> </target> <!-- (system, modules) --> <target name="remove_unused" depends="pack_to_phar"> <delete dir="${deploy_dir}/system" /> <delete dir="${deploy_dir}/modules/auth" /> <delete dir="${deploy_dir}/modules/cache" /> <delete dir="${deploy_dir}/modules/database" /> <delete dir="${deploy_dir}/modules/orm" /> </target> <!-- ! --> <target name="build" depends="remove_unused" /> </project>
Source: https://habr.com/ru/post/124536/
All Articles