Skip to content

Architecture

Martin Polanka edited this page Apr 26, 2017 · 9 revisions

Architecture

@todo: php application which might use some of the features of php 7, build on top of the nette framework

@todo: discussed only important parts of the system or the interesting ones

Nette Overview

@todo: nette in general

@todo: DI

Handling of Exceptions

By default in production mode Nette runtime will catch all exceptions thrown during execution and engage exception handler. Exception handler is defined within configuration and points to user defined Error presenter. In the CUK system there is App\Presenters\ErrorPresenter which handles logging and sending/displaying the right error codes and pages. In here there can be engage some custom handling of some particular exception, but so far there is none.

Routing

Basic routing in Nette is quite simple and straightforward, but if there is complexity needed, it can be polished into very complex structure. Routing in CUK is fortunatelly simple and uses automatic detection of presenters and actions. This is managed through App\RouterFactory factory class in create() method.

Users Management

All features concerning users management are placed within App\Users namespace. But the most important part is how to store and authenticate logged in users. In Nette logged users and information about them are by default stored in Sessions on the server. And authentication of them is done through Nette\Security\IAuthenticator implementation.

Considering used Doctrine framework, information about user in the CUK system is stored in the User entity, so it would be handy to somehow store this entity or its identification. In CUK this is done through Nette addon https://github.com/Majkl578/nette-identity-doctrine. Of course we have to somehow engage User entity as the Nette Identity which is handled by App\Users\MyAuthenticator implementation of authentication. Because of this on every page load new information about user will be fetched from database according to stored user identification.

With users management is tightly coupled authorization of access to the resources. In CUK there are two classes concerning authorization: App\Users\AuthorizatorFactory which uses Nette basic authorization mechanism and App\Users\MyAuthorizator which somehow handles cases where basic authorization fails. The list of all users roles can be found in App\Users\AuthorizatorFactory in create() function, alongside with definitions of resources and permission rules. For some humanly readable description of user roles there is App\Users\RolesManager helper.

Database Layer

There is no reason to use plain SQL thus database abstraction was engaged, specifically well-known Doctrine 2 ORM framework. Configuration of Doctrine was described previously in Configuration article. All repositories and entities are placed within App\Model namespace, repositories are in subnamespace Repository and entities in Entity.

@todo: database

@todo: fixtures

Remote Loading

@todo: guzzlehttp and how datas are loaded from ifmsa.org

Tables and PDFs Generation

@todo: libraries

Payment Gateway

More about payment gateway, its implementation and integration within external service, can be found in separate article Payment Gateway.

Clone this wiki locally