You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get per [Git](https://git-scm.com/) or download and use it.
25
+
26
+
```php
27
+
<?php
28
+
define('MBT_DOCUMENT_ROOT', __DIR__);
29
+
require_once './autoload/src/class.Loader.php';
30
+
?>
31
+
<!DOCTYPE html>
32
+
<html>
33
+
<head>
34
+
<metacharset="UTF-8">
35
+
<title>MB tnado Ai - Autoload</title>
36
+
</head>
37
+
<body>
38
+
<?php
39
+
40
+
// METHOD 1: Fastest way, the namespace is foldername structure and filename is equal to filename
41
+
$class_one = new testclasses\classOne();
42
+
$class_one->method_from_class_one();
43
+
44
+
// METHOD 2: The slower way, namespace is equal to folder structure but the classname is differnt to the filename
45
+
$class_two = new testclasses\classes\class_two();
46
+
$class_two->method_from_class_two();
47
+
48
+
// METHOD 3: The slowest way, here ist nothing euqal
49
+
$three_class = new name_space\namespace2\three_class();
50
+
$three_class->method_from_three_class();
51
+
52
+
?>
53
+
</body>
54
+
</html>
55
+
```
56
+
57
+
## Packagist with Composer
58
+
59
+
This solution extends the vendor autoloader because it calls the files with certain criteria. The extension allows you to call classes wherever the Autloder is involved.
60
+
61
+
Autoload and package in **composer.json**
62
+
```json
63
+
{
64
+
"autoload": {
65
+
"psr-4": { "Aautoloder\\": "autoload/src" }
66
+
},
67
+
"require": {
68
+
"prod3v3loper/php-auto-autoloader": ">=1.0"
69
+
},
70
+
```
19
71
20
72
```php
21
73
<?php
22
-
require_once 'init.php';
74
+
define('MBT_DOCUMENT_ROOT', __DIR__);
75
+
require_once __DIR__ . '/vendor/autoload.php';
76
+
new \Aautoloder\Loader(array(MBT_DOCUMENT_ROOT));
23
77
?>
24
78
<!DOCTYPE html>
25
79
<html>
@@ -46,6 +100,7 @@ require_once 'init.php';
46
100
</body>
47
101
</html>
48
102
```
103
+
49
104
# Debug
50
105
51
106
`autoload/core.config.php`
@@ -69,7 +124,7 @@ DEFAULT: `MBT_DOCUMENT_ROOT`
69
124
The autoloader define get the web root by self on require the `init.php`
0 commit comments