Routes for React

This commit is contained in:
Kilian Hofmann 2024-07-22 04:27:02 +02:00
parent 20db2301cb
commit 06ce614c2b
3 changed files with 13 additions and 9 deletions

View File

@ -11,11 +11,11 @@ RewriteRule ^ api/index.php [L,NC,QSA]
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !/api/docs RewriteCond %{REQUEST_FILENAME} !/api/docs
RewriteCond %{REQUEST_FILENAME} !/dist RewriteCond %{REQUEST_FILENAME} !/dist
RewriteRule ^ dist [L,NC,QSA] RewriteRule ^ dist/index.html [L,NC,QSA]
## Rewrite all files unless in the directories specified ## Rewrite all files unless in the directories specified
RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !/storage/.* RewriteCond %{REQUEST_FILENAME} !/storage/.*
RewriteCond %{REQUEST_FILENAME} !/dist/.* RewriteCond %{REQUEST_FILENAME} !/dist/.*
RewriteCond %{REQUEST_FILENAME} !/api/docs RewriteCond %{REQUEST_FILENAME} !/api/docs
RewriteRule ^ dist [L,NC,QSA] RewriteRule ^ dist/index.html [L,NC,QSA]

View File

@ -8,21 +8,25 @@ class Input
{ {
public static function post(string $index, $defaultValue = null) public static function post(string $index, $defaultValue = null)
{ {
return Request::request()->getInputHandler()->post($index, $defaultValue); $value = Request::request()->getInputHandler()->post($index, $defaultValue);
return empty($value) ? null : $value->getValue();
} }
public static function patch(string $index, $defaultValue = null) public static function patch(string $index, $defaultValue = null)
{ {
return Request::request()->getInputHandler()->post($index, $defaultValue); $value = Request::request()->getInputHandler()->post($index, $defaultValue);
return empty($value) ? null : $value->getValue();
} }
public static function get(string $index, $defaultValue = null) public static function get(string $index, $defaultValue = null)
{ {
return Request::request()->getInputHandler()->get($index, $defaultValue); $value = Request::request()->getInputHandler()->get($index, $defaultValue);
return empty($value) ? null : $value->getValue();
} }
public static function file(string $index, $defaultValue = null) public static function file(string $index, $defaultValue = null)
{ {
return Request::request()->getInputHandler()->file($index, $defaultValue); $value = Request::request()->getInputHandler()->file($index, $defaultValue);
return empty($value) ? null : $value->getValue();
} }
} }

6
exam/dist/.htaccess vendored
View File

@ -1,7 +1,7 @@
RewriteEngine On RewriteEngine On
RewriteBase /phpCourse/exam/dist/ RewriteBase /phpCourse/exam/dist
## Frontend routing required all non files to be rewritten to the entry point ## Disallow direct entry over the dist
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L,NC,QSA] RewriteRule ^ / [L,NC,QSA,F]