:
, ( ), " ". , (, n , , ).
class User{
private $name;
private $password;
}
, -, , .
class UserService{
function __construct(IUserProvider $userProvider){
$this->userProvider = $userProvider
}
function getUsers(){
return $this->userProvider->getUsers();
}
}
, , , , , json , webservice:
class UserProvider implements IUserProvider{
function __construct(Connection $connection){
$this->connection = $connection;
}
function getUsers(){
return $this->toUsers($this->connection->fetchAssoc("Select * from users"));
}
function toUsers(array $datas){
(...)
return $users;
}
}
interface IUserProvider{
function getUsers();
}
, , . , , 2 . UserProvider, CommentProvider.
3 :
- ( , ...)
- ( -, , , ACL , ...)
- , ,
- , .
, .
, , : https://github.com/Mparaiso/silex-bookmarkly
.