{"_id":"56b537147bccae0d00e9a1d0","user":"56b534d0168b5c1700c159a7","project":"56b534f15f1cf00d00cc4759","version":{"_id":"56b534f25f1cf00d00cc475c","project":"56b534f15f1cf00d00cc4759","__v":4,"createdAt":"2016-02-05T23:49:06.439Z","releaseDate":"2016-02-05T23:49:06.439Z","categories":["56b534f35f1cf00d00cc475d","56b55e5b5f1cf00d00cc477c","56b55e605f1cf00d00cc477d","56b5fac7e205510d001e4cfe"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"56b534f35f1cf00d00cc475d","__v":10,"project":"56b534f15f1cf00d00cc4759","version":"56b534f25f1cf00d00cc475c","pages":["56b534f45f1cf00d00cc475f","56b5368185a6922300d1c538","56b5369a168b5c1700c159a9","56b536b4eed075230097d75e","56b536c32d7fc00d0037f496","56b5370a5997532100bc6c30","56b537147bccae0d00e9a1d0","56b537252d7fc00d0037f498","56b5372e5997532100bc6c32","56b5373d7719bb190014307a"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-05T23:49:07.518Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"githubsync":"","__v":5,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-05T23:58:12.362Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"We've learned how to run experiments, but what about our findings? It would be a shame to throw all the lovely information away.\n\nScientist uses Journals to export experiment data into a range of different data-stores. Right now, the project is young, and there are very few Journals, but as the projects progresses, there will be Journals for Redis, Elasticsearch, MySQL and more.\n\nBy throwing your data into a datastore, we can examine and chart it with a tool such as Grafana or Kibana. We can find patterns in our trials, and determine whether our experiments have been valuable.\n\nTo create a Journal, we need to implement the `Scientist\\Journals\\Journal` interface. Here's an example.\n\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nnamespace MyApp;\\n\\nuse Scientist\\\\Report;\\nuse Scientist\\\\Experiment;\\nuse Scientist\\\\Journals\\\\Journal;\\n\\nclass RedisJournal implements Journal\\n{\\n    /**\\n     * Dispatch a report to storage.\\n     *\\n     * :::at:::param \\\\Scientist\\\\Experiment $experiment\\n     * @param \\\\Scientist\\\\Report     $report\\n     *\\n     * @return mixed\\n     */\\n    public function report(Experiment $experiment, Report $report)\\n    {\\n\\t\\t\\t  // Ship experiment information across to Redis (for example).\\n    }\\n}\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nThe experiment instance is the experiment that has been executed. The instance contains a number of getters for useful properties.\n\nThe report instance will be covered in detail in the next chapter.\n\nJournals use the observer/observable pattern, and thus need to be registered to Laboratory before they will receive experiment data.\n\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$laboratory->addJournal(new \\\\MyApp\\\\RedisJournal);\\n\\n// OR\\n\\n$laboratory->setJournals([\\n    new \\\\MyApp\\\\RedisJournal,\\n    new \\\\MyApp\\\\AnotherJournal\\n]);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nAs you can see, you can use the `addJournal()` method on the Laboratory to register new journal instances for reporting. Alternatively, you can use the `setJournals()` method with an array of Journal instances to set many Journals at once.\n\nAll registered Journals will receive *all* experiment results.\n\nThat's all there is to it! I'm hoping that lovely people will contribute a bunch of re-usable Journals for common data storage systems. *When* this happens, I'll update this page with a list of links to them.","excerpt":"Report findings to Journals.","slug":"journals","type":"basic","title":"Journals"}

Journals

Report findings to Journals.

We've learned how to run experiments, but what about our findings? It would be a shame to throw all the lovely information away. Scientist uses Journals to export experiment data into a range of different data-stores. Right now, the project is young, and there are very few Journals, but as the projects progresses, there will be Journals for Redis, Elasticsearch, MySQL and more. By throwing your data into a datastore, we can examine and chart it with a tool such as Grafana or Kibana. We can find patterns in our trials, and determine whether our experiments have been valuable. To create a Journal, we need to implement the `Scientist\Journals\Journal` interface. Here's an example. [block:code] { "codes": [ { "code": "<?php\n\nnamespace MyApp;\n\nuse Scientist\\Report;\nuse Scientist\\Experiment;\nuse Scientist\\Journals\\Journal;\n\nclass RedisJournal implements Journal\n{\n /**\n * Dispatch a report to storage.\n *\n * @param \\Scientist\\Experiment $experiment\n * @param \\Scientist\\Report $report\n *\n * @return mixed\n */\n public function report(Experiment $experiment, Report $report)\n {\n\t\t\t // Ship experiment information across to Redis (for example).\n }\n}\n", "language": "php" } ] } [/block] The experiment instance is the experiment that has been executed. The instance contains a number of getters for useful properties. The report instance will be covered in detail in the next chapter. Journals use the observer/observable pattern, and thus need to be registered to Laboratory before they will receive experiment data. [block:code] { "codes": [ { "code": "<?php\n\n$laboratory->addJournal(new \\MyApp\\RedisJournal);\n\n// OR\n\n$laboratory->setJournals([\n new \\MyApp\\RedisJournal,\n new \\MyApp\\AnotherJournal\n]);", "language": "php" } ] } [/block] As you can see, you can use the `addJournal()` method on the Laboratory to register new journal instances for reporting. Alternatively, you can use the `setJournals()` method with an array of Journal instances to set many Journals at once. All registered Journals will receive *all* experiment results. That's all there is to it! I'm hoping that lovely people will contribute a bunch of re-usable Journals for common data storage systems. *When* this happens, I'll update this page with a list of links to them.