{"action":"created","issue":{"url":"https://api.github.com/repos/php-fig/fig-standards/issues/44","repository_url":"https://api.github.com/repos/php-fig/fig-standards","labels_url":"https://api.github.com/repos/php-fig/fig-standards/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/php-fig/fig-standards/issues/44/comments","events_url":"https://api.github.com/repos/php-fig/fig-standards/issues/44/events","html_url":"https://github.com/php-fig/fig-standards/issues/44","id":5496925,"number":44,"title":"Event based programming","user":{"login":"Marlinc","id":1240253,"avatar_url":"https://avatars.githubusercontent.com/u/1240253?v=3","gravatar_id":"","url":"https://api.github.com/users/Marlinc","html_url":"https://github.com/Marlinc","followers_url":"https://api.github.com/users/Marlinc/followers","following_url":"https://api.github.com/users/Marlinc/following{/other_user}","gists_url":"https://api.github.com/users/Marlinc/gists{/gist_id}","starred_url":"https://api.github.com/users/Marlinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marlinc/subscriptions","organizations_url":"https://api.github.com/users/Marlinc/orgs","repos_url":"https://api.github.com/users/Marlinc/repos","events_url":"https://api.github.com/users/Marlinc/events{/privacy}","received_events_url":"https://api.github.com/users/Marlinc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2012-07-09T11:51:07Z","updated_at":"2016-02-15T13:37:17Z","closed_at":null,"body":"Why not create a standard for event based programming in PHP?\n\nSo if you have a application with loop you can use the standard that describes events.\n\nSo you have a event like this:\n\n```php\n<?php\n\nabstract class Event\n{\n\n    public $nameLevel = 2;\n\n    public function getName()\n    {\n        return end(explode('\\\\', get_class($this), $this->nameLevel + 1));\n    }\n\n}\n```\n\nAnd a event-handler like this:\n\n```php\n<?php\n\nclass EventHandler\n{\n\n    static protected $callbacks = array();\n    \n    protected $events           = array();\n    \n    public static function raise(Event $event)\n    {\n        foreach (self::$callbacks[$event->getName()] as $callback) {\n            call_user_func($callback, $event);\n        }\n    }\n    \n    public static function addCallback(event, $callback)\n    {\n        self::$callbacks[$event->getName()][] = $callback;\n    }\n\n}\n```\n\nSo you can add a callback to a event with:\n\n```php\n<?php\n\nfunction onClick(Event $event)\n{\n    printf('Raised event %s', $event->getName) . PHP_EOL:\n}\n\nEventHandler::addCallback(new Clicked(), 'onClick');\n```\n\n\nAnd you're able to raise the event with:\n\n```php\n<?php\n\nEventHandler::raise(new Clicked());\n```\n\nI'm sorry if this doesn't look the way you wan't it but this is just my idea. I'm open to suggestions and would like to get some feedback. And possibly event a standard for event based applications.\n\nAlso how do you think about event-based data like a 'nickname' for a user when he joins a IRC channel. Should this information be saved in a extended event class. In the raise method. Or something else?"},"comment":{"url":"https://api.github.com/repos/php-fig/fig-standards/issues/comments/184211347","html_url":"https://github.com/php-fig/fig-standards/issues/44#issuecomment-184211347","issue_url":"https://api.github.com/repos/php-fig/fig-standards/issues/44","id":184211347,"user":{"login":"michaelcullum","id":211740,"avatar_url":"https://avatars.githubusercontent.com/u/211740?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelcullum","html_url":"https://github.com/michaelcullum","followers_url":"https://api.github.com/users/michaelcullum/followers","following_url":"https://api.github.com/users/michaelcullum/following{/other_user}","gists_url":"https://api.github.com/users/michaelcullum/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelcullum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelcullum/subscriptions","organizations_url":"https://api.github.com/users/michaelcullum/orgs","repos_url":"https://api.github.com/users/michaelcullum/repos","events_url":"https://api.github.com/users/michaelcullum/events{/privacy}","received_events_url":"https://api.github.com/users/michaelcullum/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T13:37:17Z","updated_at":"2016-02-15T13:37:17Z","body":"We discuss new proposals for PSRs on the mailing list first normally. If you'd like to continue with this, please suggest it on there where we can discuss it going to a potential entrance vote.\r\n\r\nhttps://groups.google.com/forum/#!forum/php-fig"}}