PHP Classes

frdl Application Components Access Wrapper: Register and access objects with aliases

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 129 All time: 9,359 This week: 455Up
Version License PHP version Categories
frdl-app 1.0.8BSD License5.3PHP 5, Language
Description 

Author

This class can register and access objects with aliases.

It can register class objects and assign them shortcut alias names.

The registered objects can be referred and called using the registered shortcuts.

The class can also assign anonymous function to given object functions, so when those object functions are called, the class will call the assigned functions.

Innovation Award
PHP Programming Innovation award nominee
May 2015
Number 2


Prize: One copy of the Zend Studio
Sometimes when developers need to access objects that access other objects you need to to create variables to avoid typing too much to specify those object references.

However, when using fluent function calling, it is not convenient to assign variables to objects that may result from the calls to those objects.

This class provides an alternative that consists in assigning alias names to the intermediary objects that may result from fluent function calls.

It can also dynamically add anonymous functions to classes, so it can be used as plugin system for instance.

Manuel Lemos
Picture of Till Wehowski
  Performance   Level  
Name: Till Wehowski <contact>
Classes: 30 packages by
Country: Germany Germany
Age: 45
All time rank: 107269 in Germany Germany
Week rank: 321 Up11 in Germany Germany Up
Innovation award
Innovation award
Nominee: 12x

Example

<?php

require 'App.php';

/*
 * declaring an class for later using as alias
 * */
class myClass extends PDO {}

frdl\webfan\App::God(false, "Demo", null, false)
 
/*
  * predefined when init===true
  */
 
-> addShortCut('$', array(frdl\webfan\App::God(),'addShortCut'))
 
 
/*
   * Using Shortcut https://github.com/frdl/webfan/wiki/Lambada-Overloading-Syntax
   */
 
-> {'$'}('!write', (function($arg){$a = func_get_args(); echo $a[0];}) )
  ->{
'$'}('lnbr', (function(){echo '<br />'."\r\n";}) )
 
 
/*
   * Using Aliasing https://github.com/frdl/webfan/wiki/Aliasing
   */
 
-> setAlias('DB Wrapper', '\myDB', '\myClass', '\PDO',array())
  ->
mapAliasing(false)
  ->
applyAliasMap(true)
  ->
lnbr()
 ;


 
 
frdl\webfan\App::God()
  ->
lnbr()
  ->{
'$'}('showexamplecode', (function(){echo highlight_file(__FILE__, true);}) )
  ->
showexamplecode()
  ->
lnbr()
  -> {
'!write'}('Outputs: ')
  -> {
'!write'}('Hello world')
  -> {
'!write'}(' - and your PDO drivers')
  ->
lnbr()
  ;
 
  echo
print_r(\myDB::getAvailableDrivers(), true);
 
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file A.php Class Class source
Accessible without login Plain text file App.php Class Class source
Accessible without login Plain text file example.php Example Example
Accessible without login Plain text file o.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 75%
Total:129
This week:0
All time:9,359
This week:455Up