Autoloading (PSR-4)
Në shqip: Ngarkimi automatik i klasave
ShpjegimiSQ
Me autoloading, s'ke pse shkruan require për çdo klasë: Composer-i e ngarkon vetë skedarin kur e përdor klasën. Rregulli PSR-4 thotë që namespace-i dhe dosjet përputhen — App\Models\Nxenes gjendet te app/Models/Nxenes.php.
EnglishEN
With autoloading, you don't write require for every class: Composer loads the file automatically when you use the class. The PSR-4 rule says namespaces and folders match — App\Models\Student lives in app/Models/Student.php.
Si ta mendosh
Si bibliotekari që ta sjell librin sapo e kërkon, pa pasur nevojë ta marrësh vetë nga rafti.
Lexoje në anglisht
Like a librarian who brings you the book the moment you ask, without you fetching it.
Shembull kodiphp
<?php
require __DIR__ . "/vendor/autoload.php";
use App\Models\Nxenes;
$n = new Nxenes("Arta"); // skedari ngarkohet vetë