pragmaMx Support Forum

pragmaMx => Coder und Bastlerecke => Thema gestartet von: Webfan am 28 Februar 2015, 08:47:40

Titel: Autoloading for PragmaMx
Beitrag von: Webfan am 28 Februar 2015, 08:47:40

/**
* (c) - by webfan.de (TW)
*
*
*      This file demonstrates how to implement psr-4 autoloading into
*      the PragmaMx CMS.
*
*      Readme: Just include and edit this file!
*
*     [color=red]  EDIT SourceLoader.php to DISABLE Remote-Autoloading![/color]
*/

http://frdl.de/frdlpmx-bridge.zip

Titel: Re:Autoloading for PragmaMx
Beitrag von: Sven4972 am 01 März 2015, 09:53:42
Hallo,

wie wäre es dann mal mit einer genauen Beschreibung, bevor ich mir irgendwas runterlade?


LG
Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 01 März 2015, 10:30:36
Hallo Sven,
sorry, momentan habe ich dafür keine Zeit.
Der Beitrag ist im Bereich "Coder und Bastlerecke" und richtet sich an (die) Entwickler, bei denen ich vorraussetze, daß sie den Code lesen können.
Mehr Informationen u.U. zu gegebener Zeit.

Einen schönen Sonntag wünsche ich Allen!

Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 01 März 2015, 10:41:56
...es geht lediglich darum ein Beispiel aufzuzeigen für ein "vernünftiges" Autoloading.
Es handelt sich um eine "Bridge" für pmx und meinem Projekt http://frdl.github.io/webfan/
Bridge ist hier zuviel gesagt, Beispiel datei ist die bridge.php im zip Paket:

<?php
/**
 * (c) - by webfan.de (TW)
 * 
 * 
 *      This file demonstrates how to implement psr-4 autoloading into
 *      the PragmaMx CMS.
 * 
 *      Readme: Just include and edit this file!
 * 
 *       EDIT SourceLoader.php to DISABLE Remote-Autoloading!
 */

defined('mxMainFileLoaded') or die('access denied');


$dir_lib =  realpath(__DIR__DIRECTORY_SEPARATOR 'webfan-master' DIRECTORY_SEPARATOR'lib' DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

require 
$dir_lib 'frdl' DIRECTORY_SEPARATOR 'webfan' DIRECTORY_SEPARATOR 'Autoloading'  DIRECTORY_SEPARATOR 'SourceLoader.php';
require 
$dir_lib 'frdl' DIRECTORY_SEPARATOR 'webfan'.DIRECTORY_SEPARATOR 'App.php';


$Woggle frdl\webfan\App::God(true"frdl - AC - PragmaMx Bridge (schmeckt.at)"'frdl\webfan\Autoloading\SourceLoader'false)
      ->
init_autoloader(true)
    -> addNamespace(''$dir_lib ,  true)  
        -> 
addNamespace('webdof\\'$dir_lib 'webdof'.DIRECTORY_SEPARATOR,  false)
        -> 
addNamespace('webfan\\'$dir_lib 'webfan'.DIRECTORY_SEPARATOR,  false)
        -> 
addNamespace('frdl\\'$dir_lib 'frdl'.DIRECTORY_SEPARATOR,  false)
   ->
j()
   
   
//example:
->{'$'}('o', (function($arg){$a func_get_args(); echo $a[0];}) )
-> {'o'}('Hello world')

  
;

:puzzled: :BD:
Titel: Re:Autoloading for PragmaMx
Beitrag von: Sven4972 am 01 März 2015, 10:46:05
Hallo,

danke für die Info.


LG Sven
Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 04 März 2015, 13:01:11
Hallo allerseits,
es gibt hier nun einen Wiki zur Dokumentation:
https://github.com/frdl/webfan/wiki
:bye:
Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 04 März 2015, 13:04:59
Um das remote Autoloading zu deaktivieren, Beispiel:


<?php
//...
/**
*
* Disable remote autoloading:
*
**/

webfan\Loader::top()
          ->  
unregister(array(webfan\Loader::top(),'autoloadClassFromServer'))
  ;

//...
?>

Titel: Re:Autoloading for PragmaMx
Beitrag von: Twerk am 13 März 2015, 12:10:36
Und das kann ich einfach runterladen ja?
Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 13 März 2015, 13:14:58
Hallo Twerk,
ZitatUnd das kann ich einfach runterladen ja?
Ja, hier z.B.: https://github.com/frdl/webfan
Lizenz: BSD style https://github.com/frdl/webfan/blob/master/LICENSE.md

Viele Grüße
Till
Titel: Re:Autoloading for PragmaMx
Beitrag von: Twerk am 13 März 2015, 16:52:36
Super, vielen lieben Dank fürs bereitstellen  :thumbup:
Titel: Autoloading for PragmaMx
Beitrag von: shorty am 13 Mai 2015, 15:32:25
Hello !  :smile:

is it working with pmx 1.12 ?
Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 14 Mai 2015, 08:08:24
Hello shorty,
yes, I have this library running succesfully in for example pmx 1.12.1, 2.1.2, and some modified systems...
Maybe modifications are necessary or recommended.
As this is for Autoloading it is usefull to place it at the beginning of your script, for example mainfile.php .

Over time since the first post, I added some changes.
ZitatThe frdl\webfan\Autoloading\SourceLoader autoloader class provides to use the following autoloader strategies or a mix of them within one application:

   psr-0
   psr-4
   class mapping
   Remote (RPC)
You can find the wiki as well as the source at github:
Autoloading (Wiki) (https://github.com/frdl/webfan/wiki/Autoloading)

You can also find the latest version at phpclasses.org.
I am also nominated for an award April 2015, please vote for the class, if you like it (click on "vote" to do it ...):
http://www.phpclasses.org/package/9071-PHP-Autoload-classes-with-PSR-0-PSR-4-mapping-etc-.html

:bye:

Edit:
<?php
/**
 * SourceLoader example usage
 */

require 'SourceLoader.php';

frdl\webfan\Autoloading\SourceLoader::top()
   -> 
addPsr4('frdl\\'DIRECTORY_SEPARATOR 'pathToDir' DIRECTORY_SEPARATORtrue)
   -> 
addPsr0('aNamespace\\'DIRECTORY_SEPARATOR 'pathToDir-Old' DIRECTORY_SEPARATORfalse)
   -> 
class_mapping_add('MyClass'DIRECTORY_SEPARATOR 'pathToDir' DIRECTORY_SEPARATOR .'cl.MyClass.php'$success)
   -> 
autoload_register()
   -> 
unregister(array(frdl\webfan\Autoloading\SourceLoader::top(),'autoloadClassFromServer'))

Titel: Re:Autoloading for PragmaMx
Beitrag von: Webfan am 03 Januar 2016, 03:41:05
Further:
https://github.com/frdl/webfan/issues/16
https://github.com/frdl/webfan/wiki/Troubleshooting