Modular Scaffold
nathggns opened this issue · 24 comments
In order to retain the "lightweight" description, we need to make some modifications. It's actually pretty hefty at the moment.
One thing that would certainly become a module is the database side, which includes the following classes.
ModelDatabase
DatabaseDriverPDO
DatabaseDriverInterface
DatabaseDriverSqlite
DatabaseDriver
DatabaseBuilderInterface
DatabaseBuilderSql
DatabaseBuilderSqlite
DatabaseBuilder
Database
Every driver and builder would be its own module, apart from SQL
,SQLite
and PDO
.
However, there are some other classes that could become parts of a module too, namely:
Validate
There are some others that aren't necessarily core classes, but could be needed by the core:
Inflector
Error
Shutdown
Dummy
Dynamic
Current Tasklist
- Remove Dummy
Create Logger
- STDOUT Logger
- Web Logger
- Make error and response use logger.
Every module would need it's own bootstrap.php
, config/*
and functions.php
. Maybe services.php
and routes.php
even...
Speaking of that, we should split system/bootstrap.php
into bootstrap.php
and services.php
. Create the ability for routes.php
to exist too.
Dummy and Dynamic should be removed, the rest should be part of the core. I think the router should be a module too. Actually, everything should be a module that isn't part of the system around the modules, such as services, the autoloader and configuration system.
However, which modules should be separate, and which should be bundled with the core framework?
The issue with removing Dynamic
is that assigning functions as property's are difficult without it.
Dummy
should definitely be removed. How did that even make it in?!
I'd love to remove Shutdown
and Dynamic
, but it's difficult, as there are a lot of bugs in PHP that are so annoying.
How should the new structure of Scaffold look?
I'm thinking something like this
Core
- Autoload
- Config
- Dynamic
- Inflector
- Shutdown
- Error
- Response
- Model
- Controller
- Service
- ExceptionService
Bundled Modules
Web
- Router
- Request
- ExceptionRouting
Validator
- Validate
- ExceptionValidate
Separate Modules
Database (Already established what would be in this one)
Response would also be in the Web module
What does Shutdown
do? Remove dynamic though. Rather use a temporary variable to call the function, or call_user_func()
.
It's like a gateway between PHPs shutdown function system and Error. Allows you to unset a shutdown function, basically.
Why is that needed? Don't set it if you don't want to set it. You can use exit()
within the shutdown function to prevent other shutdown functions to be executed.
I actually don't remember why I added it, I believe it solved a bug though...
Problem: Error relies on Response
Error should use a Logger class, which can be assigned loggers for CLI, JSON, HTML etc.
Modules should have their own namespace each.
But then those Loggers will eventually need a Response class of some kind. :S
Yes, the Web module will implement a Web logger.
And what will the default loggers log to, a file? STDOUT?
there should be loggers for both included with the core, yes.
Which would be the default?
In production it should log to a file, in development it should log to STDOUT by default. But that should be set by the configuration.
Okay cool.
The Web Module will of course be included by default right?
Yes.
But it shouldn't be part of the core module, obviously.