]> git.mxchange.org Git - friendica.git/blobdiff - doc/autoloader.md
setting current date to the CHANGELOG
[friendica.git] / doc / autoloader.md
index 1a3b9a55b1034b258e43a06bce5653140ed7cdd9..954c28813c870593834b54761222d3ef19aac688 100644 (file)
@@ -6,7 +6,7 @@ Autoloader with Composer
 
 Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
 
-It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
+It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application.
 
 * [Using Composer](help/Composer)
 
@@ -39,7 +39,6 @@ Namespaces are useful to keep classes separated and avoid names conflicts (could
 
 Let's say now that you need to load some items in a view, maybe in a fictional `mod/network.php`.
 In order for the Composer autoloader to work, it must first be included.
-In Friendica this is already done at the top of `boot.php`, with `require_once('vendor/autoload.php');`.
 
 The code will be something like:
 
@@ -47,8 +46,10 @@ The code will be something like:
 // mod/network.php
 <?php
 
+use Friendica\App;
+
 function network_content(App $a) {
-       $itemsmanager = new Friendica\ItemsManager();
+       $itemsmanager = new \Friendica\ItemsManager();
        $items = $itemsmanager->getAll();
 
        // pass $items to template
@@ -104,7 +105,7 @@ class Dfrn {
 
 mail_post($a){
        ...
-       Friendica\dfrn::mail($item, $owner);
+       Friendica\Protocol\DFRN::mail($item, $owner);
        ...
 }
 ```
@@ -117,6 +118,8 @@ If your code is in same namespace as the class you need, you don't need to prepe
 
 namespace Friendica;
 
+use Friendica\Protocol\DFRN;
+
 // this is the same content of current include/delivery.php,
 // but has been declared to be in "Friendica" namespace
 
@@ -125,12 +128,12 @@ switch($contact['network']) {
        case NETWORK_DFRN:
                if ($mail) {
                        $item['body'] = ...
-                       $atom = Dfrn::mail($item, $owner);
+                       $atom = DFRN::mail($item, $owner);
                } elseif ($fsuggest) {
-                       $atom = Dfrn::fsuggest($item, $owner);
+                       $atom = DFRN::fsuggest($item, $owner);
                        q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
                } elseif ($relocate)
-                       $atom = Dfrn::relocate($owner, $uid);
+                       $atom = DFRN::relocate($owner, $uid);
 [...]
 ```