Search the Community
Showing results for tags 'framework'.
-
ClicShopping\OM is a framework utilizing new features in PHP to improve the performance, security, and modularity of the codebase. Taking advantage of namespaces and autoloading, it is now even easier to add new features and extend existing features without the need to edit core source code files. The base framework is located in the includes/ClicShopping directory: Framework Namespace Location Core ClicShopping\OM includes/ClicShopping/OM Sites ClicShopping\Sites includes/ClicShopping/Sites Apps ClicShopping\Apps includes/ClicShopping/Apps Custom ClicShopping\Custom includes/ClicShopping/Custom Namespaces/Autoloader The framework is built utilizing the PSR-4 standard for autoloading classes from matching namespaces and file paths. Classes are automatically loaded on demand and don't need to be included/required manually. The base namespace the autoloader watches for is ClicShopping\ and loads the class files located in the includes/ClicShopping/ directory. Examples Class File Location ClicShopping\OM\CLICSHOPPING includes/ClicShopping/OM/CLICSHOPPING.php ClicShopping\OM\Db includes/ClicShopping/OM/Db.php ClicShopping\OM\Registry includes/ClicShopping/OM/Registry.php ClicShopping\Sites\Shop\Shop includes/ClicShopping/Sites/Shop/Shop.php ClicShopping\Apps\VENDOR\APP\APP includes/ClicShopping/Apps/VENDOR/APP/APP.php Classes in the framework must declare their namespace as the first PHP code in the file. Examples namespace CLICSHOPPING\OM; class NewClass { .... } The full namespace to the above example would be: ClicShopping\OM\NewClass and the location of the file would be: includes/ClicShopping/OM/NewClass.php For another class to be able to load ClicShopping\OM\NewClass automatically, it needs to be declared with PHP's use keyword after the namespace of the class and before any other PHP code. Examples namespace ClicShopping\OM; use ClicShopping\OM\NewClass; class AnotherNewClass { public function __construct() { $NewClass = new NewClass(); } } The framework autoloader (ClicShopping\OM\CLICSHOPPING::autoload()) is registered as an autoloader in includes/application_top.php and is automatically initialized in all main PHP files that include the application_top.php file. Template files do not need to have a namespace set, but still need to reference framework classes that it uses: Examples use ClicShopping\OM\HTML; echo HTML::outputProtected('Hello World!'); More information about namespaces can be found at the PHP Namespace documentation page. Sites Sites are registered in the framework to initialize and apply environment parameters specific to that site. The available sites in the core are: Site Controller Shop (default) ClicShopping\Sites\Shop\Shop Admin ClicShopping\Sites\ClicShoppingAdmin\Admin Sites are registered and retrieved as follows: use ClicShopping\OM\CLICSHOPPING; CLICSHOPPING::initialize(); CLICSHOPPING::loadSite('Shop'); $site = CLICSHOPPING::getSite(); Custom Directory To customize a core source file, copy it to this directory matching the directory structure of the original file. For example, - to make custom changes to ClicShopping/OM/Session/File.php - copy the complete file to ClicShopping/Custom/Session/File.php and perform your changes to this new file. Notes Although the custom class is copied to a Custom directory, it must retain the original Core namespace. Due to this, copied classes cannot extend the original class in the Core namespace. ClicShopping\Custom\Conf Configuration setting ClicShopping\Custom\Sites\Shop (default) Shop classes ClicShopping\Custom\OM OM classes ClicShopping\Custom\Schema Database file installation Apps Apps are self-contained packages that add new or extend existing features through modules and hooks. Apps reside in their own directory and do not need to edit core source code files. Apps are located in the following directory: Namespace Location ClicShopping\Apps\VENDOR\APP includes/ClicShopping/Apps/VENDOR/APP Apps also have a public directory for public accessible files such as stylesheets, javascript, and images, located at: public/Apps/VENDOR/APP More information is available in the Apps chapter. Service Services are portions of the online store that do not directly relate to the customer purchasing a product, but can be helpful in setting up the store. Services are available in Shop and ClicShoppingAdmin. it can use everywhere inside the site. Example Service for the mail namespace ClicShopping\Service\Shop; use ClicShopping\OM\Registry; use ClicShopping\OM\Mail as MailClass; class Mail implements \ClicShopping\OM\ServiceInterface { public static function start() { if (is_file(CLICSHOPPING_BASE_DIR . 'OM/Mail.php')) { Registry::set('Mail', new MailClass()); return true; } else { return false; } } public static function stop() { return true; } } How to call inside a file : $CLICSHOPPING_Mail = Registry::get('Mail');