murph-doc/search/search_index.json

1 line
93 KiB
JSON
Raw Normal View History

2024-03-31 17:19:55 +02:00
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to Murph","text":"<p>Murph is an open-source CMF built on top of Symfony that helps you to build your own CMS with several domains and languages. It comes with a fully implemented and customizable tree manager, a CRUD generator, a 2FA authentication, settings and tasks managers, basic web analytics.</p> <p>Symfony developers will love build on Murph \ud83d\udcaa End users will be fond of the interface and the powerful tools \ud83d\udc9c</p> <p>Developed with love by Simon Vieille.</p> <p>Support: Murph project on Matrix.</p> <p>Access the demo.</p>"},{"location":"abtesting/","title":"A/B Testing","text":""},{"location":"abtesting/#overview","title":"Overview","text":"<p>Murph contains a basic tools to create A/B Tests.</p> <p>The logic of the implement follows this logic:</p> <ul> <li>A node can be configured to enable A/B Test. You also define a code to set the name of the test</li> <li>When Murph receives a request, an event is dispatched and contains an <code>App\\Core\\Ab\\AbTestInterface</code> object</li> <li>You must create an event subscriber and set variations defined by<ul> <li>a name (a string)</li> <li>a value (whatever you want)</li> <li>a percentage chance (optional)</li> </ul> </li> <li>Then a variation is picked and saved in user cookies</li> <li>Finally, you can retrieve the picked variation PHP side and template side</li> </ul>"},{"location":"abtesting/#configure-the-node","title":"Configure the node","text":"<p>Go the navigation and edit the tested node:</p> <ul> <li>Enable A/B testing</li> <li>Define a code (eg: <code>example_test</code>)</li> </ul> <p></p>"},{"location":"abtesting/#the-event-subscriber","title":"The Event Subscriber","text":"<p>The event subscriber helps you to define each variation and the TTL.</p> src/EventSubscriber/MyAbTestEventSubscriber.php<pre><code>namespace App\\EventSubscriber;\n\nuse App\\Core\\EventSubscriber\\AbEventSubscriber as EventSubscriber;\nuse App\\Core\\Event\\Ab\\AbTestEvent;\n\nclass MyAbTestEventSubscriber extends EventSubscriber\n{\n public function onInit(AbTestEvent $event)\n {\n if ($event-&gt;getTest()-&gt;getName() !== 'example_test') {\n return;\n }\n\n $event-&gt;getTest()\n -&gt;addVariation('test_1', 'Value #1', 20) // 20% of chance\n -&gt;addVariation('test_2', 'Value #2', 30) // 30% of chance\n -&gt;addVariation('test_3', 'Value #3', 50) // 50% of chance\n -&gt;setDuration(3600 * 24) // duration of the cookie in seconds\n ;\n }\n\n public function onRun(AbTestEvent $event)\n {\n // executed if a variation is newly picked\n }\n}\n</code></pre>"},{"location":"abtesting/#the-result","title":"The result","text":"<p>you can retrieve the test and the variation picked in PHP side and in template side.</p> <pre><code>use App\\Core\\Ab\\AbContainerInterface;\n\npublic function foo(AbContainerInterface $testContainer)\n{\n if ($testContainer-&gt;has('example_test')) {\n $test = $testContainer-&gt;get('example_test');\n\n $result = $test-&gt;getResult(); // eg: \"test_2\"\n $value = $test-&gt;getResultValue(); // eg: \"Value #2\"\n\n // ...\n }\n\n // ...\n}\n</code></pre> <pre><code>{% if ab_test_exists('example_test') %}\n {% set test = ab_test('example_test') %}\n {% set result = ab_test_result('example_test') %}\n {% set value = ab_test_value('example_test') %}\n\n {# ... #}\n{% endif %}\n</code></pre>"},{"location":"abtesting/#global-ab-test","title":"Global A/B Test","text":"<p>If you need to perform an A/B test everywhere, you need to create a specific listener:</p> src/EventListener/CustomAbListener.php<pre><code>namespace App\\EventListener;\n\nuse App\\Core\\EventListener\\AbListener as EventListener;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpKernel\\Event\\RequestEvent;\n\nclass CustomAbListener extends EventListener\n{\n /**\n * {