Skip to content

Commit 73488df

Browse files
committed
composer-autoloading
1 parent 8c2612d commit 73488df

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

composer.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "dasci/php-basic-lessons",
3+
"authors": [
4+
{
5+
"name": "ismaildasci",
6+
"email": "[email protected]"
7+
}
8+
],
9+
"require": {},
10+
"autoload": {
11+
"psr-4": {
12+
"Core\\": "Core/",
13+
"Http\\": "Http/"
14+
}
15+
}
16+
}

composer.lock

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22

33
use Core\Session;
44

5-
session_start();
6-
75
const BASE_PATH = __DIR__ . '/../';
86

9-
require BASE_PATH . 'Core/functions.php';
7+
require BASE_PATH . '/vendor/autoload.php';
108

11-
require base_path('Core/response.php');
9+
session_start();
1210

13-
spl_autoload_register(function ($class) {
14-
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
11+
require BASE_PATH . 'Core/functions.php';
1512

16-
require base_path("{$class}.php");
17-
});
13+
require base_path('Core/response.php');
1814

1915
require base_path('bootstrap.php');
2016

17+
2118
$router = new \Core\Router();
2219
$routes = require base_path('routes.php');
2320

0 commit comments

Comments
 (0)