Package creationIntroductionPackage is the smallest unit in the Ultimix Framework. Each package a set of php and javascript code, language files, templates, css files, images, configs, any other data and of course nested packages. Some of them may be omitted. Each package can be accessed by calling core function get_package, wich takes 3 parameters - package name, package version (can be set to 'last' - it means that the last version of the package will be returned) and __FILE__ as a third parameter. This function works as a singleton and returns reference to the stored object. If you want to create a brand new package's object use get_package_object with the same parameters.Example:
$Security1 = get_package( 'security' , 'last' , __FILE__ ); $Security2 = get_package( 'security' , 'last' , __FILE__ ); # here $Security1 and $Security2 are the same Example:
$Security1 = get_package_object( 'security' , 'last' , __FILE__ ); $Security2 = get_package_object( 'security' , 'last' , __FILE__ ); # here $Security1 and $Security2 are two differnet objects Package's directory structureAll packages have almost the same directory structure wich can be seen below:package_directory / | +---conf | +---data | | | +---page | | | +---permit | | | +---static_content | +---packages | | | +---core | | | +---data | +---res | | | +---css | | | +---images | | | +---lang | | | +---template | +---include | | | +---js | | | +---php | +---tmpYou certanly can use your own structure, but numerous features were adopted for the directory structure wich is listed above. Package creation steps1. Go to the directory packages;2. Create there the directory wich name is <package_directory> (for example - it is not necessary that names of the package and it's directory should match); 3. Open the file /packages/core/data/package_list and append a new string <package_name>;.<package_version>;#<package_directory> Example:
where 1.0.0 is the package's version.
security.1.0.0#security 4. Then go to the directory /packages/<package_directory> and create file <package_name>.php wich contains class <package_name>_<package_version*>. Example:
File <package_name>.php may be omitted, then the function 'get_package' will return false.
class security_1_0_0 { function s() { } } That's all! Th created package can be accessed by calling function get_package. Example:
$Security = get_package( '<package_name>' , '<package_version>' , __FILE__ ); Each package may have nested packages. To create them create the file (if it does not exist) /packages/<package_directory>/packages/core/data/package_list go to the directory /packages/<package_directory>/packages and use the above steps. Example:
# access to the nested package can provided like this: $obj = get_package( 'master_package::nested_package' , 'last' , __FILE__ ); # 1 $obj = get_package( 'master_package::nested_package' , 'last::last' , __FILE__ ); # 2 # here 1 and 2 are the same # some other examples $obj = get_package( 'master_package::nested_package' , '1.2.3::last' , __FILE__ ); $obj = get_package( 'master_package::nested_package' , 'last::3.2.1' , __FILE__ ); $obj = get_package( 'master_package::nested_package' , '1.2.3::3.2.1' , __FILE__ ); |
2009 © ultimix |