You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daniel Spors edited this page Nov 11, 2020
·
2 revisions
WDF autoloading follows a simple approach: Classes must be stored in files named <lowercaseclassname>.class.php where <lowercaseclassname> must not be full qualified, but the classname only.
Search paths for the autoloader are defined using the classpath_add function and searched in the order they were added.
Let's say you defined some classes in the controller folder and some others in the model folder like this:
// controller/home.class.phpclass Home extends HtmlPage { }
// controller/search.class.phpclass Search extends HtmlPage { }
// model/usermodel.class.phpclass UserModel extends Model { }
// model/accountmodel.class.phpclass AccountModel extends Model { }
All you need to do is add the root folder to the classpath:
// inside index.phpclasspath_add(__DIR__);
From now on you can use all classes following the naming scheme everywhere.
// again in controller/home.class.phpclass Home extends HtmlPage
{
functionVerifyUser($username,$password)
{
$user = UserModel::Make()
->eq('username',$username)
->eq("password",sha1($password))
->current();
}
}