PHP Classes

AFW Examples: Examples and tests of usage of Ascoos Framework

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-01-04 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: 20 This week: 3All time: 11,339 This week: 9Up
Version License PHP version Categories
afw-examples 25.0.0Custom (specified...8.2Graphics, Tools, PHP 8
Description 

Author

This package provides example scripts that use the Ascoos Framework to show how to use classes and functions.

Currently, it provides example scripts that:

- Handles arrays with extra statistical analysis and charts

- Handles Disks and files system.

- Handles dates with extra operations.

- Handles network operations.

- Handles API operations.

- Handles Cache operations.

- Etc.

Picture of ASCOOS CMS
  Performance   Level  
Innovation award
Innovation award
Nominee: 13x

 

Instructions

For the chart examples (or any example that requires a font) to run correctly, you need to download the folder FONTS

Example

<?php
/**
 * __ _ ___ ___ ___ ___ ___ ____ _ __ ___ ___
 * / _` |/ / / __/ _ \ / _ \ / / / __/| '_ ` _ \ / /
 * | (_| |\ \| (_| (_) | (_) |\ \ | (__ | | | | | |\ \
 * \__,_|/__/ \___\___/ \___/ /__/ \___\|_| |_| |_|/__/
 *
 *
 ************************************************************************************
 * @ASCOOS-NAME : ASCOOS CMS 25' *
 * @ASCOOS-VERSION : 25.0.0 *
 * @ASCOOS-CATEGORY : Framework (Frontend and Administrator Side) *
 * @ASCOOS-CREATOR : Drogidis Christos *
 * @ASCOOS-SITE : www.ascoos.com *
 * @ASCOOS-LICENSE : [Commercial] http://docs.ascoos.com/lics/ascoos/AGL.html *
 * @ASCOOS-COPYRIGHT : Copyright (c) 2007 - 2025, AlexSoft Software. *
 ************************************************************************************
 *
 * @package : ASCOOS FRAMEWORK Examples
 * @subpackage : Handles APCu-based Cache.
 * @source : afw-examples/classes/TCacheHandler/TCacheAPCuHandler.php
 * @fileNo :
 * @version : 25.0.0
 * @build : 10829
 * @created : 2024-07-01 20:00:00 UTC+2
 * @updated : 2025-01-01 07:00:00 UTC+2
 * @author : Drogidis Christos
 * @authorSite : www.alexsoft.gr
 * @license : AGL-F
 *
 * @since PHP 8.2.0
 */
declare(strict_types=1);

require_once
"../../autoload.php";

use
ASCOOS\FRAMEWORK\Kernel\{
   
Core\TObject,
   
Cache\Apcu\TCacheAPCuHandler
};

/******************************************************************************
 * @startcode TExampleAPCuObject
 *****************************************************************************/
/**
 * @class TExampleAPCuObject
 * @extends TObject
 *
 * @summary Example object using APCu for caching.
 *
 * [ PROPERTIES ]
 * @property $cacheHandler Protected Property for APCu Cache Handler.
 *
 * [ METHODS ]
 * @method void __construct(array $properties = []) Initialize the class with given properties.
 * @method mixed fetchData(string $cacheKey) Fetch data from the cache if available, or retrieve from the source.
 * @method array getCacheStat() Get statistics from APCu.
 * @method void clearCache(?string $cacheKey = null) Clears cache, optionally for a specific key.
 */
class TExampleAPCuObject extends TObject
{
    protected
$cacheHandler;

   
/**
     * Constructor.
     *
     * @desc <English> Initialize the class with given properties.
     * @desc <Greek> ??????????? ??? ????? ?? ??? ??????????? ?????????.
     *
     * @param array $properties <English> An associative array of properties to initialize the class with.
     * <Greek> ???? ????????????? ??????? ????????? ??? ??? ???????????? ??? ??????.
     */
   
public function __construct(array $properties = [])
    {
       
parent::__construct($properties);
       
$this->cacheHandler = new TCacheAPCuHandler(3600);
    }

   
/**
     * Fetch data from cache or source.
     *
     * @desc <English> Fetch data from the cache if available, or retrieve from the source.
     * @desc <Greek> ?????? ???????? ??? ??? cache ??? ????? ????????? ? ??? ??? ????.
     *
     * @param string $cacheKey <English> The key for the cache.
     * <Greek> ?? ?????? ??? ??? cache.
     * @return mixed <English> The fetched data.
     * <Greek> ?? ?????????? ????????.
     */
   
public function fetchData(string $cacheKey): mixed
   
{
       
$cachedData = $this->cacheHandler->checkCache($cacheKey);
        if (
$cachedData) {
            return
$cachedData;
        }

       
// Simulate data retrieval from a data source (e.g., database)
       
$data = ['data' => 'sample data'];

       
// Save data to cache
       
$this->cacheHandler->saveCache($cacheKey, $data);

        return
$data;
    }

   
/**
     * Get Cache Statistics.
     *
     * @desc <English> Get statistics from APCu.
     * @desc <Greek> ???? ??????????? ??? APCu.
     *
     * @return array <English> Array containing APCu statistics.
     * <Greek> ??????? ?? ?? ?????????? ??? APCu.
     */
   
public function getCacheStat(): array
    {
        return
$this->cacheHandler->getStats();
    }

   
/**
     * Clear Cache.
     *
     * @desc <English> Clear cache, optionally for a specific key.
     * @desc <Greek> ?????????? cache, ??????????? ??? ???????????? ??????.
     *
     * @param ?string $cacheKey <English> The key for the cache (optional).
     * <Greek> ?? ?????? ??? ??? cache (???????????).
     */
   
public function clearCache(?string $cacheKey = null): void
   
{
       
$this->cacheHandler->clearCache($cacheKey);
    }
}

/*
<English> Example of use the TExampleAPCuObject class
<Greek> ?????????? ?????? ??? ?????? TExampleAPCuObject
*/
$example = new TExampleAPCuObject([
   
'config' => [
       
'extensions' => [
           
'subExtension1' => ['version' => '1.0.0'],
           
'subExtension2' => ['enabled' => true]
        ],
       
'newProperty' => 'newValue'
   
]
]);

/*
<English> Get data using cache.
<Greek> ???????? ????????? ??????????????? ??? cache.
*/
$data = $example->fetchData('example_key');
print_r($data);
print_r($example->getCacheStat());
//$example->clearCache('example_key');

$example->Free($example);


Screenshots (8)  
  • screenshots/bar_chart.png
  • screenshots/bar_multidimensional_chart.png
  • screenshots/box_plot.png
  • screenshots/correlation_multidimensional_matrix.png
  • screenshots/density_multidimensional_plot.png
  • screenshots/donut_chart_multidimensional.png
  • screenshots/gantt_chart.png
  • screenshots/pie_chart_multi.png
  Files folder image Files (121)  
File Role Description
Files folder imageclasses (4 directories)
Files folder imageconfig (1 file)
Files folder imagefunctions (2 files)
Files folder imagehelp (21 files)
Accessible without login Plain text file autoload.php Aux. Configuration script
Accessible without login Plain text file LICENSE_AGL-F.md Lic. License text

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadafw-examples-2025-01-04.zip 379KB
Downloadafw-examples-2025-01-04.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Ascoos Framework Download .zip .tar.gz Implement Ascoos Framework 24 code Required
 Version Control Unique User Downloads Download Rankings  
 100%
Total:20
This week:3
All time:11,339
This week:9Up