PHP code example of hughcube / laravel-knight
1. Go to this page and download the library: Download hughcube/laravel-knight library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hughcube / laravel-knight example snippets
# model
class User extends \HughCube\Laravel\Knight\Model{
public function getCache() {
return null;
}
}
$user = User::findById(1); // model of User
$user = User::findById(null); // null
$users = User::noCacheQuery()->findByPks([1]); // collection of User
# action
class Action extends \HughCube\Laravel\Knight\Routing\Controller{
public function action() {
return $this->getOrSet(__METHOD__, function (){
return 'HELLO WORLD';
});
}
}