PHP

Routing in plain PHP (front controller)

Në shqip: Rrugëzimi në PHP

ShpjegimiSQ

Në PHP-në e thjeshtë, çdo skedar .php është një faqe. Në projekte më të mëdha, të gjitha kërkesat shkojnë te një index.php i vetëm (front controller), që e lexon adresën dhe vendos cilin kod të ekzekutojë — kështu punojnë Laravel-i dhe Symfony.

EnglishEN

In plain PHP, every .php file is a page. In bigger projects, all requests go to a single index.php (the front controller), which reads the address and decides what code to run — that's how Laravel and Symfony work.

Si ta mendosh

Si recepsioni i hotelit: të gjithë hyjnë nga e njëjta derë dhe dërgohen te dhoma e duhur.

Lexoje në anglisht

Like a hotel reception: everyone comes through the same door and gets sent to the right room.

Shembull kodiphp

$rruga = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
match ($rruga) {
  "/" => require "faqet/kreu.php",
  "/kontakt" => require "faqet/kontakt.php", default => http_response_code(404),
};

Terma të lidhur