vendredi 17 janvier 2014

ILN (Intuitive Language Notation) configuration language

I really like YAML language for object configuration, but I was thinking about something more basic, something simpler, easy accessible without have to take some hours to completely learn a syntax.

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\PdoDriver
    __construct:
        hostname: localhost
        username: root
        password:
        database: test
        port: 3603
The first instruction is the alias of the namespace.
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\PdoDriver
    __construct:
        hostname: localhost
        username: root
        password:
        database: test
        port: 3603
    setTable:
        name: blog
You can also include aliases like this:
db.driver: \TTI\DbUtil\PdoDriver
    setTable:
        name: %cache.driver%
You can also add type to variables like this:
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