Please Note
This software is NOT production ready!
Its just my personal playground currently :), (*1)
Installation
Via composer create-project, (*2)
composer create-project bleicker/framework-base
Setup
Sql Settings, (*3)
cp Configuration/Secrets.Example.php Configuration/Secrets.php
Run cli command to create the db and build needed tables:, (*4)
vendor/bin/doctrine orm:schema-tool:update --force --dump-sql
Start a php server process either in development- or production context
Production:, (*5)
CONTEXT=production nohup php -S localhost:8001 -t Public >> /dev/null 2>&1 &
Development:, (*6)
nohup php -S localhost:8000 -t Public >> /dev/null 2>&1 &
Open your browser and visit either Development-Server or Production-Server, (*7)
Switch to MySql
If you want to use mysql instead of sqlite adjust the driver in Secrets.php f.e. to, (*8)
['url' => 'mysql://user:secret@localhost/mydb']
And run, (*9)
vendor/bin/doctrine orm:schema-tool:update --force --dump-sql
Doctrine Mapping
For persistence Doctrine is in use.
By default i am using its yml configuration to bind models and mapping informations.
Simply add your yaml configuration in Configuration/Schema/Persistence/ Folder. And refresh you db using the doctrine command line, (*10)
vendor/bin/doctrine orm:schema-tool:update --force --dump-sql
See Doctrine Docs, (*11)
Routes
See Configuration/Routing.php to get some small examples how to introduce new Routes., (*12)
See FastRoute Docs, (*13)
Templating
I introduced namelesscoder's fluid decoupled version as default template engine.
Templates are located in the Folder "Templates" an resolved by the namespace of called Controller::Action.
See Fluid Docs, (*14)
Your App Stuff
A good location for your Controllers/Services/DomainModels etc is the "App" Folder, (*15)
Registry
Add something:, (*16)
Registry::add('foo.bar.baz', 'Hello World');
Getting Registry entry everywhere in your code, (*17)
Registry::get('foo.bar.baz');
ObjectManager
Add Object, (*18)
ObjectManager::register(MyClassInterface::class, new MyClass('foo', 'bar'));
Getting the Object everywhere in your Code with, (*19)
ObjectManager::get(MyClassInterface::class);
Registering a Closure as Factory
Add Closure, (*20)
ObjectManager::register(MyClassInterface::class, function(){new MyClass()});
To make it a singleton just register it as this:, (*21)
ObjectManager::makeSingleton(MyClassInterface::class);
Getting the Object everywhere in your Code with, (*22)
ObjectManager::get(MyClassInterface::class);
TypeConverter
TypeConverter can be used to convert some source to a defined target type., (*23)
Register a TypeConverter, (*24)
Converter::register('registrationFormDto', new RegistrationFormDtoConverter());
Convert a source, (*25)
Converter::convert($postData, RegistrationFormDtoConverter::class);
Controller Security
To secure a Controller::Action you can add a Vote to the AccessVoter Object.
The Vote receives a Closure wich could be anything you want. The arguments
of the Controller will be passed to this closure. So if you need them, use them.
See this example, (*26)