-
-
Notifications
You must be signed in to change notification settings - Fork 6
Page Logic
A page response is made up of a Page View, which can be seen as the HTML that makes up the presentation of the page, and optional Page Logic, which can be seen as the PHP that makes the page dynamic.
A Page Logic file acts as the point-of-entry for executing the business logic of a request. In terms of MVC architecture, Page Logic is the controller.
A request must have a view to respond with, but the logic is completely optional. Some pages of web applications can be treated as static, so wouldn't require any PHP logic to complete the response, but when you need to manipulate the page, react to user input, and output data to the page, logic becomes necessary.
Like with Page Views, routing of Logic files is automatic and matches the URI.
Application business logic can be autoloaded from Composer packages or the Class project directory, both using PSR-4, but Page Logic behaves slightly differently.
For Page Logic, rather than having class names and file paths mapped to PSR-4 namespaces, they are mapped to the URI that triggers them.
// TODO: Try to keep logic files as simple as possible, deferring as much work into application classes as possible - easier to maintain and less tightly bound logic to particular URIs.
// TODO.
// Camel case function names.
// Passing all InputData
- when passing data to other classes use opt-in with
or without
functions.
// TODO: Read more in the User input section.
// TODO: List of all properties (document, database, etc.)
// TODO: Similar to concept of autowiring in Symfony.
Website | Packagist | CircleCI | Scrutinizer
- Request-response lifecycle
- Running your application
- Project layout
- Application architecture
- Web servers
- URIs
- Page view
- Dynamic URIs and pages
- Headers and footers
- Page logic
- Protected globals
- User input
- Cookies
- Sessions
- DOM manipulation
- Custom HTML components
- DOM templates
- Binding data to the DOM
- Database
- Client side assets
- API Webservices
- Security
- Configuration
- Build system
- Coding styleguide