I thought about a file extension, ILN for Intuitive Language notation.
The principle is simple, very simple for now.
When you have something inside a ILN config file:
db.driver: \TTI\DbUtil\PdoDriverThe first instruction is the alias of the namespace.
__construct:
hostname: localhost
username: root
password:
database: test
port: 3603
The second instruction separated by 4 spaces is mandatory the name of a method.
The other instructions separated by 4 spaces too, are the arguments of the method they're in, specified in the same order as in the real class.
If you have to comment some configurations, you just have to write like this:
#cache.driver: \TTI\CacheUtil\MemCache
# __construct:
# cache_hostname: xxxxx
# cache_port: xxxx
You can add multiple dependencies for a driver:
db.driver: \TTI\DbUtil\PdoDriverYou can also include aliases like this:
__construct:
hostname: localhost
username: root
password:
database: test
port: 3603
setTable:
name: blog
db.driver: \TTI\DbUtil\PdoDriverYou can also add type to variables like this:
setTable:
name: %cache.driver%
db.driver: \TTI\DbUtil\PdoDriver
setTable:
name: array| 'table' => 'blog'
That's all for the moment.
But at this point, it is fully clear and easily reachable.
You are able to do some dependency injection, and use a service container in your application.
You can concretely use it with ILN Parser, you can download via composer:
require: "edouardkombo/parser-strategy": "1.0.0.*@dev"
I was thinking about adding some instructions later to handle Observer design pattern for events handling. It will come soon.
It is just a beginning, always in the spirit of having fun by coding our applications.
Thanks.
Aucun commentaire:
Enregistrer un commentaire