I want to include a class that has been made to the php file, here I am using .htaccess. but once put into a php file, the php class can not be opened or loaded in a php file. The following directory structure in my web.
htdocs/
mysite/
src/
App/
Login.php <-- class file php
public/
login.php <-- file php
this is login class (mysite/src/App/Login.php)
class Login {
private $username;
//etc...
}
this is login file (mysite/public/login.php)
require('../src/App/Login.php');
$login = new Login();
this is .htaccess file (mysite/.htaccess)
Options +FollowSymLinks
RewriteEngine On
# skip for existing files/directories (/assets will be skipped here)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# for public directory
rewritecond %{REQUEST_URI} !^/public/(.*)
RewriteRule .* index.php [L]
and index.php for rule in .htaccess file (mysite/index.php)
$requested = empty($_SERVER['REQUEST_URI']) ? false : $_SERVER['REQUEST_URI'];
$server_name = str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
switch ($requested) {
case $server_name:
include 'public/index.php';
break;
case $server_name.'login':
include 'public/login.php';
break;
default:
include 'public/404.php';
}
but when I open localhost/mysite/login there is an error
Warning: require(../src/App/Login.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mysite\public\login.php on line ...
Fatal error: require(): Failed opening required '../src/App/Login.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\mysite\public\login.php on line ...
Can you help me?
thank you