Includes autoloader and routing.
Tested on PHP7 and Apache2
sudo a2enmod rewrite
- Configure
apache2.conf
Needs AllowOverrride All for htaccess rewrite
<Directory /path/to/webroot/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Allow from localhost
</Directory>
- Request URIs follow this pattern
/controller/method/param1/paramN
- Configuration
- Add new routes in
/config/Routes.php
- Add new namespaces in
/config/Namespaces.php
- Add new routes in
- Configuration
- Interfaces
- List of Intefaces in Core (src/)
- Controller - instantiates Service and View
- Service - instantiates mappers, business logic classes, and entities (returns)
- Mapper - uses DBHelper for repository queries
- Entity - Getters/Setters store for View
- View - uses entities and renders views/templates
- List of Intefaces in Core (src/)
- Exceptions
- Update /public/index.php with new exception classes to catch them
- Uncaught excpetions go to Exception|Error handled and logged with error code
- Tests
- Only test classes under app directory
- Unit - where no other resource (class, filesystem, database, etc) is needed for the method being tested
- Integration - where other resources are included in the test
- Functional - client tests (eg rendered page, api response, etc)
# ##
# ## ##
# ## ##
# ## Client ## <-------------------------------------------+
# ## ## |
# ## ## |
# ## |
# | |
# v |
# ################## ################## ################
# # # # # # #
# # index.php # ------> # controller #-------> # View #
# # # # # # #
# ################## ################## ################
# | ^ ^
# | | |
# v | v
# ################## +--------------+
# # # | |
# # Service # | Templates |
# # # | |
# ################## +--------------+
# ^
# +--------------------+--------------------+
# v v v
# ################## ################## ################
# # # # # # #
# # Mapper # # BL Classes # # Entity #
# # # # # # #
# ################## ################## ################
# ^
# |
# v
# ##########
# # #
# # #
# # DB #
# # #
# # #
# ##########
#
- Inspirations from: https://github.com/andrejrs/php-mvc-example