Skip to content

Commit 959a21c

Browse files
committed
composor autoloading
1 parent 0f91e24 commit 959a21c

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

composer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "user/organized-stuff",
3+
"authors": [
4+
{
5+
"name": "drdixit",
6+
"email": "drdixit6@gmail.com"
7+
}
8+
],
9+
"require": {},
10+
"autoload": {
11+
"psr-4": {
12+
"Core\\": "Core/",
13+
"Http\\": "Http/"
14+
}
15+
}
16+
}

composer.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
use Core\Session;
44
use Core\ValidationException;
55

6+
const BASE_PATH = __DIR__.'/../';
7+
8+
require BASE_PATH.'vendor/autoload.php';
9+
610
session_start();
711

8-
const BASE_PATH = __DIR__.'/../';
912

1013
require BASE_PATH.'Core/functions.php';
1114

12-
spl_autoload_register(function ($class) {
13-
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
15+
// we are going to use composer's autoloading
16+
// spl_autoload_register(function ($class) {
17+
// $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
18+
19+
// require base_path("{$class}.php");
20+
// });
1421

15-
require base_path("{$class}.php");
16-
});
22+
// require BASE_PATH.'vendor/autoload.php';
1723

1824
require base_path('bootstrap.php');
1925

0 commit comments

Comments
 (0)