generic-repository / phalcon
By Edward Hieatt and Rob Mee: Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/generic-repository/phalcon
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2025-10-12 00:46:54 UTC
README
Generic repository for Phalcon-framework
Move the folder named 'repository 'somewhere in your project.In my case it will be vendor. Then, at your services file:
/**
* Autoload repository
*/
include __DIR__ . "/../../vendor/repository/autoload.php";
/**
* Generic Repository
*/
$dependencyInjector['repository'] = new GenericRepository($config, 'user');
At some Controller :
/**
* List all created pages
*
* @link /page - method GET
* @link /page/1 - method GET
*/
public function indexAction($id)
{
if (!empty($id)) {
echo $this->repository->setModel('Page')->setCriteria(array("id = '$id'"))
->mergeResults()
->findFirst()
->getRelated(array('articles', 'comments'))
->returnAs('json');
exit;
}
echo $this->repository->setModel('Page')
->mergeResults()
->findAll()
->getRelated(array('articles', 'comments'))
->returnAs('json');
exit;
}