switch to autoload
This commit is contained in:
parent
4798e0fdbe
commit
97b654006a
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
.claude
|
.claude
|
||||||
|
test_*.php
|
||||||
7
App.php
7
App.php
@ -2,13 +2,6 @@
|
|||||||
|
|
||||||
namespace Web;
|
namespace Web;
|
||||||
|
|
||||||
require_once __DIR__ . '/HTTPMethod.php';
|
|
||||||
require_once __DIR__ . '/Request.php';
|
|
||||||
require_once __DIR__ . '/Response.php';
|
|
||||||
require_once __DIR__ . '/Context.php';
|
|
||||||
require_once __DIR__ . '/Router.php';
|
|
||||||
require_once __DIR__ . '/ErrorHandler.php';
|
|
||||||
require_once __DIR__ . '/Cookies.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App is the application controller itself
|
* App is the application controller itself
|
||||||
|
|||||||
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace Web;
|
namespace Web;
|
||||||
|
|
||||||
require_once __DIR__ . '/Session.php';
|
|
||||||
require_once __DIR__ . '/Validator.php';
|
|
||||||
require_once __DIR__ . '/Cookies.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context holds the request, response, and shared state for a request
|
* Context holds the request, response, and shared state for a request
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Web;
|
namespace Web;
|
||||||
|
|
||||||
require_once __DIR__ . '/Cookies.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response class represents an HTTP response
|
* Response class represents an HTTP response
|
||||||
|
|||||||
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace Web;
|
namespace Web;
|
||||||
|
|
||||||
require_once __DIR__ . '/User.php';
|
|
||||||
require_once __DIR__ . '/../Session.php';
|
|
||||||
require_once __DIR__ . '/../Cookies.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplified Auth handles user authentication with external verification
|
* Simplified Auth handles user authentication with external verification
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Web;
|
namespace Web;
|
||||||
|
|
||||||
require_once __DIR__ . '/Auth.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AuthMiddleware provides authentication checks for routes
|
* AuthMiddleware provides authentication checks for routes
|
||||||
|
|||||||
25
autoload.php
Normal file
25
autoload.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
spl_autoload_register(function ($class) {
|
||||||
|
// Class map for all Web namespace classes
|
||||||
|
static $classMap = [
|
||||||
|
'Web\\App' => __DIR__ . '/App.php',
|
||||||
|
'Web\\Context' => __DIR__ . '/Context.php',
|
||||||
|
'Web\\Cookies' => __DIR__ . '/Cookies.php',
|
||||||
|
'Web\\ErrorHandler' => __DIR__ . '/ErrorHandler.php',
|
||||||
|
'Web\\HTTPMethod' => __DIR__ . '/HTTPMethod.php',
|
||||||
|
'Web\\Request' => __DIR__ . '/Request.php',
|
||||||
|
'Web\\Response' => __DIR__ . '/Response.php',
|
||||||
|
'Web\\Router' => __DIR__ . '/Router.php',
|
||||||
|
'Web\\Session' => __DIR__ . '/Session.php',
|
||||||
|
'Web\\Validator' => __DIR__ . '/Validator.php',
|
||||||
|
'Web\\Auth' => __DIR__ . '/auth/Auth.php',
|
||||||
|
'Web\\AuthMiddleware' => __DIR__ . '/auth/AuthMiddleware.php',
|
||||||
|
'Web\\User' => __DIR__ . '/auth/User.php',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Check if class exists in the map
|
||||||
|
if (isset($classMap[$class])) {
|
||||||
|
require_once $classMap[$class];
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user