-`settings`: Configuration files for Slim Settings (_`*.local.php` are deployment specific files and ignored by git_)
-`data`: Directory for storing related application files
-`cache`: Directory for cache files
-`config`: Directory to cache merged configuration
-`templates`: Twig's autogenerated cache files
-`db`: 'Database schema and other database related files`
- `log`: Log files
- `tmp`: Temporary directory
- `uploads`: Directory for uploaded files
- `module`: Directory for application modules
- `public`: Webserver Document root
-`test`: Unit test files
- `vendor`: Composer dependencies
## Special files
-`public\index.php`: Appliction entry point
-`config\{,*.}{global,local}.php`: Configuration files; \*.global.php are loaded first and then can be overriden by \*.local.php
-`app/dependencies.php`: Wiring dependencies
-`app/middleware.php`: Application middleware
-`app/routes.php`: All application routes
- `config/app.config.php`: Main application configuration. Sets modules and config cache path
- `config/dev.config.php.dist`: Application configuration for development. Create a `dev.config.php` to include development related modules and to disable config caching.
- `config/settings/{,*.}{global,local}.php`: Configuration files for Slim settings; `*.global.php` are loaded first and then can be overridden by `*.local.php`
- `public/index.php`: Application entry point
## Application configuration and settings
### Application config
Modules to include are defined in `config/app.config.php` file.
The order of module definition matters if a module depends from another. For example, if ModuleA depends on ModuleB, ModuleB must be defined before ModuleA.
_More information about modules in [Modular application skeleton](#modular-application-skeleton) section._
Also, in this file is defined the path to store the merged settings, that are loaded from `config/settings`. See [Slim settings files](#slim-settings-files) for more information.
``` php
<?php
return [
'modules' => [
// Modules definition. Full path for module file
'module/application/bootstrap.php',
],
// Full path for file to store merged configuration
- `sch_mm.local.php.dist`: defines api url and credentials for mm.sch.gr
- `schools.global.php`: defines settings for schools module
- `sso.local.php.dist`: defines phpCAS settings for sso.sch.gr
- `twig.global.php`: defines twig settings
## Html rendering and Templates
Application uses [Twig](http://twig.sensiolabs.org/) as template engine for rendering html.
## Modular application skeleton
Application is base on [Slim Framework](http://www.slimframework.com/) and is implemented in a modular way. There are some key concepts that should be taken in mind, in order to implement a fully functional module.
### Dependency Container
Application uses the default `Slim\Container` for handling dependencies. See http://www.slimframework.com/docs/concepts/di.html for more information.
### Autoloading
Application uses composer's autoloader `Composer\Autoload\ClassLoader` to handle class autoloading. See https://github.com/composer/composer/blob/master/doc/01-basic-usage.md#autoloading for more information.
### Application events
Application uses `Knlv\events` function to handle events. See [php-events](https://github.com/kanellov/php-events).
After `Slim\App` initialization the following events are triggered:
1. `app.autoload`: Modules that listen to this event can setup the class autoloading. Event listener should expect the `Composer\Autoload\ClassLoader` instance as argument.
2. `app.services`: Modules that listen to this event can register their services in the `Slim\Container` Dependency Container.
3. `app.bootstrap`: When this event is triggered, autoloading is completed and dependency container should contain all registered services. Modules listening for this event can register routes, or override services in the Dependency Container.
### How to define a module
A module is defined with a file which should return a Closure.
Here is a typical module implementation:
``` php
<?php
return function (Slim\App $app) {
// module initialization code
$container = $app->getContainer();
$events = $container->get('events');
$events('on', 'app.autoload', function ($autoloader) {
Master module that defines the basic services such as:
- `Slim\Views\Twig` for view
- `Monolog` for logger
- `RedBeanPHP` for database
- `Slim\Flash\Messages` for flash message service
- `Slim\Csrf\Guard` for CSRF protection
It also provides the routes for home and about pages.
#### Dependencies
- `gabordemooij/redbean`: ^4.3.1
- `slim/twig-view`: ^2.0
- `slim/csrf`: ^0.6.0
- `slim/flash`: ^0.1.0
- `kanellov/slim-twig-flash`: ^0.1
- `monolog/monolog`: ^1.13
### application_form
Module that is responsible for application form submission by schools. It renders the form and stores the submitted form in database.
It also overrides schools index view by appending application form information.
#### Dependencies
- application module
- authentication module
- schools module
- `zendframework/zend-inputfilter`: ^2.0
### assets_manager
A module that is responsible to serve asset files, like css and js from within module's directory. See [`assets_manager.global.php` in Slim settings files](#slim-settings-files).
#### Dependencies
None
### authentication
Module that provides user authentication against database. The module includes the view for login page.
#### Dependencies
- application module
- `zendframework/zend-authentication`: ^2.0
- `zendframework/zend-crypt`: ^2.0
### authorization
The module that provides the acl service and assigns role to users. See [`acl.global.php` in Slim settings files](#slim-settings-files).
#### Dependencies
- authentication module
- `zendframework/zend-permissions-acl`: ^2.0
### debug
This module should only be enabled during development and in a production deployment. It provides a debug logger and enables extensive information in error messages.
#### Dependencies
- application module
### sch_inventory
It provides the service for retrieving school's rooms and equipment from http://inventory.sch.gr.
#### Dependencies
- `guzzlehttp/guzzle`: ^6.1
### sch_ldap
It initilizes an ldap connection with sch.gr. See [`ldap.local.php.dist` in Slim settings files](#slim-settings-files).
#### Dependencies
- `zendframework/zend-ldap`: ^2.0
### sch_mm
Module for retrieving extensive information about school from http://mm.sch.gr.
#### Dependencies
- `guzzlehttp/guzzle`: ^6.1
### sch_sso
Module that enables SSO with http://sso.sch.gr. Schools use this authentication method.
It overrides login view.
#### Dependencies
- application module
- authentication module
- authorization module
- `jasig/phpcas`: 1.3.4
### sch_sync
Module that gathers information from the other sch services and stores school's information in local database.
#### Dependencies
- application module
- authentication module
- sch_inventory module
- sch_ldap module
- sch_mm module
- schools module
### schools
This module provides the services, views and javascript for schools to submit the staff, rooms, equipment and software.
#### Dependencies
- application module
- `zendframework/zend-inputfilter`: ^2.0
## Run it:
1. `$ cd gredu_labs`
2. `$ php -S 0.0.0.0:8888 -t public public/index.php`
3. Browse to http://localhost:8888
**Warning:** assets_manager module does not work with php-server sapi. Assets from modules will have to be copied in `public` directory by hand.