I use custom MVC framework. I want to use annotations above action to display title in view like:
class controller {
/**
* @title = some title
*/
public function action(){
}
}
To do this I use ReflectionMethod::getDocComment and then parse comment using simple Regex, make title as global variable and use it in my view. Of course, this is a solution but really bad one because in future I may need to use annotations not just for defining titles (for example, to define rules in models. Like Symphony does).
My problem is that I have no idea where to save metadata.
I don’t think its a great idea to store front end/public information in a docblock comment, its very unwieldy as you’re discovering and not very intuitive for other developers who come along after you. Comments should be kept for documentation and meta information about the internal workings of the system.
To store information like that you should either use a database, some kind of class variable or an external configuration/language file. An even better alternative is some kind of templating library to handle things like page titles & view loading, which you can then call from the controller method and define the information there.