PhileCMS / Phile

A flat file CMS with a swappable parser and template engine.
https://philecms.github.io/
Other
257 stars 49 forks source link

Core Refactoring #317

Closed Schlaefer closed 6 years ago

Schlaefer commented 6 years ago

This is a pull request for the changes laid out in #316. I think it strikes a reasonable balance between:

New Config directory

Core Changes

Bootstrapping

The bootstrap-process isn't hardcoded in the core anymore. Advanced users can influenced it in config/boostrap.php.

New global Container object

A new PSR-11 compatible Phile\Core\Container-class for global objects is introduced, which should serve as sole source for global objects in the future.

It is configured in config/container.php.

Event access

Static access to Phile\Core\Event is deprecated. The event-bus is available via the Container, access with Container::getInstance()->get('Phile_EventBus').

Router access

Accessing the router via new Phile\Core\Router is deprecated. The router is available via Container::getInstance()->get('Phile_Router')

New Config object

Phile_Settings as in Phile\Core\Registry::get('Phile_Settings') is deprecated and handled in a new class Phile\Core\Config now.

The Config is locked after bootstrapping and before request-processing.

The Config-class is available via the Container.

E.g. instead of Registry::get('Phile_Settings')[<property>] use Container::getInstance()->get('Phile_Config')->get(<property>).

Template Var creation

Template variables derived from the config are now available via Config::getTemplateVars().

Globals deprecated

Globals are now mapped into the Config class and can be accessed through it. E.g. instead of CACHE_DIR use Container::getInstance()->get('Phile_Config')->get('cache_dir').

The global CONTENT_DIR is deprecated, access the config-variable content_dir instead.

The global CONTENT_EXT is deprecated, access the config-variable content_ext instead.

PSR-7/PSR-15

The core migrated to a PSR-7 compatible Request and Response implementation.

The core supports PSR-15 compatible middleware now. It can either be configured in config/bootstrap.php or injected by plugins via the phile.core.middleware.add-event.